We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum
Forum
Check if form submitted and success message displayed.
Hello,
I have a form which is within a content region. The form is working and returning the success message too. So no problems here.
What I would like to do is be able to see in PHP when the form has been submitted and success message is being displayed.
My form is inside a modal, and the model is closed by default. When the success message is returned unless you click to revel the modal, you don't see the success message. I have a piece of code to open the modal if there is a success message, but I don't know how to determine if the form submitted successfully.
I hope you can help.
Time Δ Debug Message
0.017 0 SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
0.0195 0.0026 Matched page: /overington, so not using routes.
0.0201 0.0006 Using master page: /templates/pages/overington_bootstrap_index.php
0.0224 0.0023 SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='52bc774207302ccaa133f0488fe81860' LIMIT 1
0.0255 0.0031 UPDATE perch2_users SET userHash='0ee0b67d3b4be96577374a8aa4ff5a8d' WHERE userID='1'
0.0277 0.0022 SELECT p.privKey FROM perch2_user_privileges p
0.0307 0.003 SELECT * FROM perch2_pages WHERE pagePath='/overington' LIMIT 1
0.0332 0.0025 SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
0.0362 0.003 Using sub-template: /templates/forms/overington_contact.html
0.0395 0.0033 SELECT * FROM perch2_forms WHERE formKey='contact' LIMIT 1
1.4372 1.3977 Sent email: "Comment from Website" to user@domain.com
1.4391 0.0018 INSERT INTO perch2_forms_responses(responseJSON,formID,responseIP,responseSpamData) VALUES('{\"fields\":{\"name\":{\"attributes\":{\"type\":\"text\",\"id\":\"name\",\"required\":\"true\",\"label\":\"Name\"},\"value\":\"Robert\"},\"email\":{\"attributes\":{\"type\":\"email\",\"id\":\"email\",\"required\":\"true\",\"label\":\"Email\",\"placeholder\":\"you@company.com\"},\"value\":\"emailme@me.com\"},\"message\":{\"attributes\":{\"type\":\"textarea\",\"id\":\"message\",\"required\":\"true\",\"label\":\"Message\"},\"value\":\"Message is here\"}},\"files\":[],\"page\":{\"id\":\"2\",\"title\":\"Overington\",\"path\":\"\\/overington\",\"navtext\":\"Overington\"}}','1','192.168.2.200','{\"fields\":[],\"environment\":{\"REDIRECT_STATUS\":\"200\",\"HTTP_HOST\":\"runway.local\",\"HTTP_CONNECTION\":\"keep-alive\",\"CONTENT_LENGTH\":\"184\",\"HTTP_CACHE_CONTROL\":\"max-age=0\",\"HTTP_ACCEPT\":\"text\\/html,application\\/xhtml+xml,application\\/xml;q=0.9,image\\/webp,*\\/*;q=0.8\",\"HTTP_ORIGIN\":\"http:\\/\\/runway.local\",\"HTTP_UPGRADE_INSECURE_REQUESTS\":\"1\",\"HTTP_USER_AGENT\":\"Mozilla\\/5.0 (Windows NT 6.1) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/47.0.2526.106 Safari\\/537.36\",\"CONTENT_TYPE\":\"application\\/x-www-form-urlencoded\",\"HTTP_REFERER\":\"http:\\/\\/runway.local\\/overington\",\"HTTP_ACCEPT_ENCODING\":\"gzip, deflate\",\"HTTP_ACCEPT_LANGUAGE\":\"en-US,en;q=0.8\",\"HTTP_COOKIE\":\"cmsa=1; PHPSESSID=0262ar5nrteb2425s4onaivbe3\",\"PATH\":\"\\/usr\\/local\\/sbin:\\/usr\\/local\\/bin:\\/usr\\/sbin:\\/usr\\/bin:\\/sbin:\\/bin\",\"SERVER_SIGNATURE\":\"<address>Apache\\/2.4.10 (Raspbian) Server at runway.local Port 80<\\/address>\\n\",\"SERVER_SOFTWARE\":\"Apache\\/2.4.10 (Raspbian)\",\"SERVER_NAME\":\"runway.local\",\"SERVER_ADDR\":\"192.168.2.229\",\"SERVER_PORT\":\"80\",\"REMOTE_ADDR\":\"192.168.2.200\",\"DOCUMENT_ROOT\":\"\\/var\\/www\\/runway-local\\/public_html\",\"REQUEST_SCHEME\":\"http\",\"CONTEXT_PREFIX\":\"\",\"CONTEXT_DOCUMENT_ROOT\":\"\\/var\\/www\\/runway-local\\/public_html\",\"SERVER_ADMIN\":\"webmaster@localhost\",\"SCRIPT_FILENAME\":\"\\/var\\/www\\/runway-local\\/public_html\\/perch\\/core\\/runway\\/start.php\",\"REMOTE_PORT\":\"58332\",\"REDIRECT_URL\":\"\\/overington\",\"GATEWAY_INTERFACE\":\"CGI\\/1.1\",\"SERVER_PROTOCOL\":\"HTTP\\/1.1\",\"REQUEST_METHOD\":\"POST\",\"QUERY_STRING\":\"\",\"REQUEST_URI\":\"\\/overington\",\"SCRIPT_NAME\":\"\\/perch\\/core\\/runway\\/start.php\",\"PHP_SELF\":\"\\/perch\\/core\\/runway\\/start.php\",\"REQUEST_TIME_FLOAT\":1451306963.282,\"REQUEST_TIME\":1451306963}}')
1.4419 0.0028 SELECT * FROM perch2_forms_responses WHERE responseID='26' LIMIT 1
1.4446 0.0027 No ids to log.
1.4452 0.0006
1.4457 0.0005 Invalidating opcache: /var/www/runway-local/public_html/perch/templates/pages/overington_bootstrap_index.php
1.4509 0.0052 SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/overington' OR regionPage='*' ORDER BY regionPage DESC
1.4561 0.0053 Time: 1.456
1.4563 0.0002 Memory: 0.7418
Want to reply to this thread?
Login with Perch
Sorry, That debug is after successful form submission.
I don't think there's a way to tell if the form validated unless you're the validating app.
Would it be an option to add the JavaScript to trigger the modal into the
<perch:success>
section of the template?Yes. That would work perfectly. I didn't really think about that.
Thank you.
I did have a working example where I was using trim() on the return, then comparing this on the result of perch_content(), but I figured there would be an easier way :)
Robert, Would you be able to share an example of the JS that you used to re-reveal the modal following form validation / errors? I'd like to use a modal for members log-in but I can't get it to persist through form validation. Thanks!
I actually just added a class to the tag in <perch:success> then used jquery to reveal.
Give me a couple minutes and I will dig it out.
:)
COOL! Thanks Robert, take your time :)
in form template
then on the php page
Brilliant! Thanks Robert, got it working like a charm.