How to reload form at bottom of content page

formuser 09 Jul, 2010
Hello,

with the help of this forum I was able a find a lot of pieces of information which I put together to build a working form with serverside validation and onsubmit code. Now I have one question left that I could not solve on my own.

My problem:
I have a form at the bottom of a long content page. When the form is submitted and there is an error (either due to an empty input field or wrong captcha) the page reloads and the top of the content page is displayed. The user does not see the error messages since they are displayed at the bottom of the page above the incomplete form. I would like to show the form directly (with the data entered so far) and its error messages.

Two options would help:
1. Is there a possibility to jump down the page to the form and its error messages?
2. Is there a possibility to open a new page without content and just the form and its error messages?

I read about redirects and onsubmit but I just can not put these pieces of information together to make it work. What line of code with what kind of link do I have to enter in which field (redirect or submit url or onsubmit before email)?

I appreciate any hints.
GreyHead 10 Jul, 2010
Hi formuser,

I guess that you could do this with a script of some kind that check for an error flag and redirects the user to the form area. You could also use a System message (if your template supports them) as these are usually displayed at the top of the page.

You can filter out minor errors - like empty inputs - using the client side JavaScript validation to reduce the number of server-side rejections.

Bob
formuser 12 Jul, 2010
Hi Bob,

thank you very much for your quick reply. I tried to find a solution at the weekend but unfortunately I am not skilled enough to make it work.

After that I did further research in the forum today I found an old thread (7095) that deals exactly with my topic:

Captcha Reload Suggestion http://www.chronoengine.com/forums.html?cont=posts&f=4&t=7095

I did exactly the same what was suggested by newstuff (Mon Sep 28, 2009) and it seems to work fine:

Comment out Line 277 inside chronoform.php (Chronocontact 3.1 RC5.5)


//$mainframe->redirect($session->get('cfreturnurl_'.$formname, '', md5('chrono')));


Since this post is already a year old and since there was no further comment I would like to ask if the approach above to modify the chronoform.php is recommendable or if this could lead to unintended consequences?

Best regards
formuser
GreyHead 12 Jul, 2010
Hi formuser,

Yes, that should work. But we generally caution against hacking the code as it tends to get forgotten when you come to upgrade. The hack will also apply to all ChronoForms on the site, not just this one.

I think you might get the same result by putting the form URL in the Redirect URL box.

Bob
formuser 12 Jul, 2010
Hi Bob,

thank you for your confirmation about hacking the code.

I also tried to insert these URLS in the Redirect URL box:

a) index.php?option=com_chronocontact&chronoformname=MyFormName
b) a URL with an anchor (mypage.html#anchor) to a bottom position of the content page where the form is displayed

But this only works after successful submission of the form. As long as there are errors due to wrong entered captcha or empty fields the page is reloaded showing the top of page.

I read in the forum that you are writing a book about chronoforms. I really look forward to get it. I once wrote a chapter for a book and it was much more work than I expected. I hope it will be easier for you. I really like the Chronoforms component and I am more than curious about all the different possibilities for creating forms.

formuser
GreyHead 12 Jul, 2010
Hi formuser,

Yes you are right about the redirect URL :-(

I'll take a look when I have a moment.

The book is complete and off with the publishers for final editing, layout and all the technical publishing stuff. They have gone quiet - which I have learned is usually OK. Last I heard was that publication is due in September . . . but I'll belive it when I have a copy in my hands.

It's around 200 pages on using ChronoForms.

Bob
michaelmedenblik 24 Dec, 2010
Hi Bob,

Few months later, I'm wondering if there is a final solution to the issue. I experience this issue and can either go for the hack in chronoforms.php or either modify the css part in chronocontact.html.php (to include - position: absolute; top:250; ). Both are not the best, I prefer that the form, inside the article, will directly position to the anchor once an error occured.

Btw, great product and amazingly flexible

Thanks,
Michael
GreyHead 24 Dec, 2010
Hi Michael,

There's nothing much else that I recall. Maybe one other thread about positioning a message.

Thinking about it, it might be possible to add some kind of a marker in the serverside vaidation and then detect that with JavaScript to move the focus to an anchor. I haven't tried it but I think it ought to be possible to get it to work.

Bob
This topic is locked and no more replies can be posted.