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

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started