Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Custom redirect after saving or cancelling a form 25 May 2015 22:45 #13183

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
I have a view from a table item, for the sake of argument called 'table1'.

index.php?option=com_mycomponent&view=table1&cid[0]=1

I have created a link from this table which opens the item form of table2 i.e

index.php?option=com_mycomponent&view=table2&layout=addform

When I click SAVE and CLOSE or CANCEL, I go back to the GRID view for table2.. as expected

I need the page to actually go BACK to the view index.php?option=com_mycomponent&view=table1&cid[0]=1

How can I override this?
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

Please Log in or Create an account to join the conversation.

Custom redirect after saving or cancelling a form 26 May 2015 20:08 #13184

Hi,

Fork the controller for view2 the item controller, not the items), change the "applyRedirection" in the save/cancel function to redirect to your table1
Check the controllers and I think it will be obvious for you. If not, I can provide example code.

edit: code added

Like I said: create a fork/controllers/table1.php, copy the function cancel() from the original controllers/table1.php and paste it into you fork.
Then change in fork like this (or similar, default might be another view in your case)
public function cancel()
{
	$this->_result = $result = parent::cancel();
	$model = $this->getModel();

	//Define the redirections
	switch($this->getLayout() .'.'. $this->getTask())
	{
		case 'table1.cancel':
			$this->applyRedirection($result, array(
				'stay',
				'com_mycomponent.table1.default'
			), array(
				'cid[]' => null
			));
			break;

		default:
			$this->applyRedirection($result, array(
				'stay',
				'com_mycomponent.table1.default'
			));
			break;
	}
}

Something like that should work (tried in my own component and works)

Please Log in or Create an account to join the conversation.

Last edit: by Romkabouter.
  • Page:
  • 1
Time to create page: 0.075 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started