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.052 seconds

Hi first of all I'd like to say that J-Cook is a great tool - the best component builder I tried so far...
Rymedia - Jonas 

Get Started