Forum
Perch forms issue
Hi
I'm trying to add a second form to a website and I've changed the ID of the form;
<perch:form id="contactTab" method="post" app="perch_forms">
and
<perch:form id="contact" method="post" app="perch_forms">
But the new form (contactTab) is going into the existing form in Admin (contact). Is there something else I need to change?
Diagnostics;
Perch: 3.1.2, PHP: 5.4.45, MySQL: mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.1.2), assets (3.1.2), categories (3.1.2), perch_blog (5.6.1), perch_forms (1.12), chirp_seo (1.3.6), pipit_sharing (1.2.0)
App runtimes: <?php $apps_list = [ 'perch_blog', 'pipit_sharing', 'perch_forms', ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/avikaaesthetic/public_html/perch
PERCH_CORE: /home/avikaaesthetic/public_html/perch/core
PERCH_RESFILEPATH: /home/avikaaesthetic/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 25M, Max POST 128M, Memory: 256M, Total max file upload: 25M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/avikaaesthetic/public_html
HTTP_HOST: www.avikaaesthetics.co.uk
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Wayne, changing the id should be the correct solution. Have you turned on debug and verified things are working as expected. Also, depending on how your form is being called, you may need to resave the region. I would either turn on debug or add some hidden comments and check the html source to make sure your form is working as you expect.
Thanks Robert
I'll check debug. Forgot to mention I re-saved the region too.
If that does not help I would also recommend posting your template here.
Thanks for the suggestions. I've gone back to a local build so I could enable debug and after setting up the second form its now working OK, so I must have got something wrong before.
One question though, I've got this form in a side tab that is hidden and slides in on click. The form goes through OK, but it doesn't load the success part, so to the user its not doing anything. Is this because its in a tab? I'm about to debug, but if you've got any ideas what it might be that would be helpful.
If the form is hidden onload, then it'll still be hidden when after the post, correct? You should check that carefully, as the same will be true for validation errors - the user wouldn't see them.
Ah, I see thank you.
I have posted a solution to this very problem before. It can be found in this forum. You basically add a class in the success part of your form which will reveal your hidden form using js. It’s been a popular solution for many.
https://forum.grabaperch.com/forum/12-28-2015-check-if-form-submitted-and-success-message-displayed
Brilliant, thank you. I do remember reading it before.
If you display the hidden form by toggling a CSS class or a data attribute to the
<from>
element, an alternative solution would be to detect the error in PHP and if an error exists, add the CSS class (or data attribute) you use to display the form.Use conditional tags in the form template to check for
contact_form_active
and add the CSS class that displays the form (assuming it's.active
):Then the user can see any errors you display inside the form with
<perch:error></perch:error>
tags.Note that this won't work if you are displaying the form with
perch_content()
, so you'd need to useperch_content_custom()
to be able to access the variablecontact_form_active
at runtime.