The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Refresh View on AJAX form Submit

Labels

This Discussion is public

Notifications

With Formidable Pro 1.07.06 it's now possible to do this, so the advice in  https://formidableforms.com/help-desk/refresh-custom-display-on-ajax-form-submit/ has become obsolete.

What you do is put your Formidable Pro View (was "custom display", is now "Views") into a div - we'll call it "MYDIV" - then create a PHP file that does nothing but load Formidable Pro Views, like so:

<?php
// get the path to wordpress
$wp_path = explode('wp-content', dirname(__FILE__));
// load it
require($wp_path[0].'wp-load.php');
// return a formidable view
echo do_shortcode('There are no views with that ID.' entry_id="'.$_GET['entry'].'" page_id='.$_GET['page'].']');
?>

For security's sake you may want to add a check for user role or what-have-you, but let's assume for now that we don't need it.

Now in the "Action After Form Submission" tab of the "Settings" area of your form, put in a snippet of jQuery.

<script>jQuery('#MYDIV').load('/do-formidable-view.php?id=my-view-slug-or-id&entry=[id]&page=1804');</script>

In the example above, I'm presuming a Formidable Pro View that only contains a single record, hence "entry_id" is included, but you can mix your own.

I've also successfully used this to enable editing of single fields via AJAX, by using an edit link in the View, setting all elements in the form to "display:none;" and then toggling the desired fields to display for a given context using jQuery. I find this a bit more useful than the "frm-entry-update-field" shortcode.

Sounds great, but I run into a couple of questions I need help with. Any suggestions?

-Where does the php file reside? WP root or in wp-content?

-Where do I enter <script>jQuery('#MYDIV').load('/do-formidable-view.php?id=my-view-slug-or-id&entry=[id]&page=1804');</script> code? The "Action After Form Submission" tab only gives me option to choose from one of the preset actions, there's no space to enter a custom action (pro version).

Thanks!

This doesn't work on a filtered view, any ideas how to implement this? Cause all i can pass is filter=>true, but how to pass filter parameters?

Tried the code provided by the topic starter. Could not get it to work.

This is the view in a div:

<div id="mydiv">

[2898]
[2899]
[2900]

</div>

This is the code in the "On Submit" text box:

Your message has send

<script>
jQuery('#mydiv').load('/load_test.php?id=8677&entry=[id]&page=7226');
</script>

Where 8677 is the view id and 7226 is the page where the view and form is on. The php file has the same text as in the post and is called load_test.php and is located in the root directory of WP.

When I submit an entry, the view is not refreshed. When I manually reload the page, the entry is shown by the view as normal. When I submit another entry, the view is updated with a error message:

"Parse error: syntax error, unexpected 'entry_id' (T_STRING) in /public/sites/mywebsiteurl/load_test.php on line 13"

Is this method still possible or did I made a mistake somewhere.

Are there Formidable Form users who got this working and willing to share their knowledge?

 

Discussion closed.