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

TOPIC:

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?

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

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

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
			));
The following user(s) said Thank You: admin, bennett.d.design

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

Last edit: by vlemos.

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.

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

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986

bennett.d.design wrote: Thanks man,

I would say... thanks girl. :P (I think)

K++
Coding is now a piece of cake

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

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

My bad! :) thanks helpful lady person ;) and Chef

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

  • Page:
  • 1
Time to create page: 0.101 seconds
  I still don't believe he can really be human to do all this ! From all of the forums that I've ever participated in this is certainly the one that most encapsulates the feeling of being truly open source where everyone's opinions and contributions can and will shape the development of the service! It's truly awesome! Hope you enjoy cooking and look forward to reading and contributing to any of the editorial work that you proposed too!! Thanks
Gez (audibleid - JED)

Get Started