Forums

Need to Redirect to Page Prior to Form Page

DocAuto 31 Dec, 2013
Hello,

I have created a ChronoForms form menu item on my Joomla! 2.5 site. I have also created a fixed position link to the page and published it on every page of the site so that a user can click to the form whenever desired. Upon submitting the form I would like for a user to be redirected to whichever page they were on when they clicked the link to the form page.

Is this possible? If so, how? =]

Thank you in advance for you help.
GreyHead 01 Jan, 2014
Hi DocAuto,

Please see this FAQ and then redirect the user at the end of the On Submit event.

Bob
DocAuto 02 Jan, 2014
Happy New Year Bob!

Thank you for the help. I'm still not having any luck though. I've added the custom element, checked the Pure Code box, and added the URL code. The redirect action is the final step in the On Submit section. It is still returning me to the home page rather than the page I was on before the form page.

Perhaps I missed a step. Am I supposed to add anything to the Redirect User action or leave it blank? Is this a situation where the Redirect URL action needs to be setup prior to the Redirect User action?

Thanks again.
GreyHead 02 Jan, 2014
Hi DocAuto,

If you use the ReDirect User action and want to set a variable URL then you need the ReDirect URL action first.

In this case as you have the URL somewhere then a custom code action will work as well:
<?php
$app =& JFactory::getApplication();
$app->redirect($form->data['page_url']);
?>
replace page_url with the name of the input with the url.

Bob
DocAuto 02 Jan, 2014
So close!

Where is, or what is, "the name of the input with the url?"
GreyHead 02 Jan, 2014
Hi DocAuto,

If you added the code exactly from the FAQ then it's page_url

Bob
DocAuto 03 Jan, 2014
Bob,

Thank you again for being so responsive. I, unfortunately, cannot seem to redirect a user to the previous page on submit. Could it be a template setting interfering?
GreyHead 03 Jan, 2014
Hi DocAuto,

Could be - hard to say. By all means email or PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

Bob
DocAuto 06 Jan, 2014
Hi Again Bob,

I sent you a PM. Thank you for the help. Hopefully we can find the culprit and this thread can be helpful to future visitors as well.
GreyHead 06 Jan, 2014
Hi DocAuto,

I think that your test form is working OK now.

The main change I made was to the hidden input code. It looks as though $doc->Base() only gives you the root of the URL. I made the code
<?php
$uri =& JFactory::getURI();
echo "<input type='hidden' name='page_url' id='page_url' value='{$uri->toString()}' />";
?>

Bob

PS I moved the cURL action down below a Show Stopper action so that the form doesn't currently submit to SalesForce, remove the Show Stopper to re-start.

PPS The Thank You page doesn't show because the redirect over-rides the display. I've left the action there for the moment but removed the other Redirect actions.
DocAuto 08 Jan, 2014
Hi Bob,

Thanks so much for looking into it. Unfortunately, it still doesn't seem to work correctly. When I submit the form it just takes me back to the form page, almost like a reset.

Now I've just set the link to open a new page and set the Thank You message to instruct users to close the window. This a little archaic but is simple enough to employ and works on all devices. =]
GreyHead 11 Jan, 2014
Hi DocAuto,

Sorry, I didn't think through the question properly. The 'Test_ChronoForm3_with_Bob_attempt_at_redirect' now works - test here.

You might need to add some code to check handle the case when the HTTP_REFERER isn't set - though if the links are all local that probably isn’t a big problem.

Bob
DocAuto 13 Jan, 2014
Thank you Bob! You nailed it. I have another question on the way, but I'll post a new thread. This problem is officially SOLVED!
This topic is locked and no more replies can be posted.