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