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.089 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