JToolBarHelper::cancel() how to pass parameters?

720 views
Skip to first unread message

Mike

unread,
Mar 17, 2013, 11:15:13 PM3/17/13
to joomla-de...@googlegroups.com
How can I pass a parameter with joomla's dot notation using JToolBarHelper::cancel()?

In my controller, I'm using a required parameter in the cancel() method.  Here's my code:

public function cancel($groupid)
{
     $app = JFactory::getApplication();
     $link = 'index.php?option=com_mycomponent&view=group&groupid=' . $groupid;
     $app->redirect($link, NULL, NULL, FALSE);
}

In my view.html.php file, I've added:

JToolBarHelper::cancel('item.cancel', 'JTOOLBAR_CANCEL');

How/where can I include the $groupid parameter to cancel()?  Or is there somewhere else I can set the redirect url?

Thanks!



Dmitry Rekun

unread,
Mar 18, 2013, 2:03:47 AM3/18/13
to joomla-de...@googlegroups.com
Hi.

You cannot. You should pass it in the hidden field and then retrieve in controller.

Dmitry

Mike

unread,
Mar 18, 2013, 10:22:39 AM3/18/13
to joomla-de...@googlegroups.com
Dimitri,

What's the "hidden" field and how do I pass the info?  What does the code look like?

Thanks!

Dmitry Rekun

unread,
Mar 18, 2013, 12:42:48 PM3/18/13
to joomla-de...@googlegroups.com
For sure you are using form. When cancel button is clicked, form is submitted. So you can pass input field inside your form like:

<input type="hidden" name="groupid" value="yourgroupid" />

Then retrieve it in controller using JInput.

Dmitry

Reply all
Reply to author
Forward
0 new messages