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

This is what you call a component builder. I was able to master using this in a very short time and the resulting component works like a charm. Not just a basic component builder but a fully working component builder with forms fields tables all ready to go. You can make the list and item views to display in the front and back end. Also there is a great forum just starting to evolve and I'm sure this will grow very rapidly when you all realise how good this tool is.
Kevin (JED)

         

Get Started