45 Posts
Jan
5 years ago
1
Topic

Hi All,

After a lot of searching and experimenting, I found a simple way to redirect a user back to the page he came from on submitting a form. It goes like this:

In the configuration of the form set the redirection to Current. Set the task of the button submit to Save or Save & Redirect. Add a field Before Store and a field After Store to the form.

Code Before Store:
$session = JFactory::getSession();
$myuri = $_SERVER['HTTP_REFERER'];
$session->set("myuri", $myuri);

Code After Store:
$session = JFactory::getSession();
$config['url'] = $session->get('myuri');

That is all!

Greetings,
Jan

Get a Book for SEBLOD
147 Posts
MtnPavlas
11 months ago
0
Level 1

Thanks for this - super helpful.

For those struggling with this (like I was) - only the 'Save and Redirect' submit button worked (just 'Save' did not).

Get a Book for SEBLOD