Welcome, Guest
Username: Password: Remember me

TOPIC: Redirect from form save to URL or Menu item

Redirect from form save to URL or Menu item 13 Jul 2016 13:44 #14225

I need to redirect from a form save to a URL or Menu Item rather than a view of the component.

for example:
case 'edituserdetails.save':
	$this->applyRedirection($result, 'index.php/members/my-account?cid=3');
break;

Can someone please help?
The administrator has disabled public write access.

Redirect from form save to URL or Menu item 13 Jul 2016 14:29 #14226

  • vlemos
  • vlemos's Avatar
  • Online
  • Elite Member
  • Posts: 295
  • Thank you received: 41
  • Karma: 21
You may need to work in the controller for "edituserdetails" with the correct syntax

public function save($key = null, $urlVar = null)
{
	CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
	//Check the ACLs
	$model = $this->getModel();
	$item = $model->getItem();
	$result = false;
	if ($model->canEdit($item, true))
	{
		$result = parent::save();
		//Get the model through postSaveHook()
		if ($this->model)
		{
			$model = $this->model;
			$item = $model->getItem();	
		}
	}
	else
		JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('COMMUTER_JTOOLBAR_SAVE')) );

	$this->_result = $result;

	//Define the redirections
	switch($this->getLayout() .'.'. $this->getTask())
	{
		case 'demoitem.save':
			$this->applyRedirection($result, array(
				'stay',
				'com_demo.useritem.useritem'
			), array(
				'cid[]' => $item->user_id
			));
Last Edit: 13 Jul 2016 14:31 by vlemos.
The administrator has disabled public write access.
The following user(s) said Thank You: admin, bennett.d.design

Redirect from form save to URL or Menu item 13 Jul 2016 14:37 #14227

Thanks man, but I was able to do it using:
case 'edituserdetails.apply':
		$this->setRedirect( "index.php/members/my-account?cid=".$model->getState('userdetails.id') );
break;
in the controllers file for the form.

Many thnaks though, You have been very helpfull.
The administrator has disabled public write access.

Redirect from form save to URL or Menu item 14 Jul 2016 09:04 #14244

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
bennett.d.design wrote:
Thanks man,
I would say... thanks girl. :P (I think)

K++
Coding is now a piece of cake
The administrator has disabled public write access.

Redirect from form save to URL or Menu item 14 Jul 2016 16:00 #14246

My bad! :) thanks helpful lady person ;) and Chef
The administrator has disabled public write access.
Time to create page: 0.056 seconds

Get Started