Title: Gravity Forms Shortcode Issue
Last modified: June 12, 2020

---

# Gravity Forms Shortcode Issue

 *  Resolved [Ian Chapman](https://wordpress.org/support/users/ianchapman/)
 * (@ianchapman)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/gravity-forms-shortcode-issue/)
 * Overall, I am SO impressed with what this plugin has done.
 * However, I have come across an issue that has stumped me. In one of the flexible
   content fields, when I insert a Gravity Forms shortcode to display a form, it
   does so, and renders visually as expected.
 * The first time I saved the page, everything worked. However, on subsequent edits
   of the page, it appears the Gravity Form is causing an issue with the page is
   modified and I click the “Update” button.
 * Instead of saving the changes, it shows a copy of the Gravity form. It is almost
   like the “Update” button is trying to post the contents of the Gravity form rather
   than the WordPress edit screen.
 * I’ve tried turning on “no conflict” mode, as well as disabling HTML5 output in
   the Gravity Forms settings page, but that didn’t resolve the issue.
 * Here are some screenshot links to show you what is happening …
 * Rendered preview of Gravity Form: [https://www.dropbox.com/s/875aozw4hiwmjel/Screenshot%202020-06-12%2012.28.48.png?dl=0](https://www.dropbox.com/s/875aozw4hiwmjel/Screenshot%202020-06-12%2012.28.48.png?dl=0)
 * Displayed after clicking “Update”: [https://www.dropbox.com/s/08y64kx4mc47pmj/Screenshot%202020-06-12%2012.21.44.png?dl=0](https://www.dropbox.com/s/08y64kx4mc47pmj/Screenshot%202020-06-12%2012.21.44.png?dl=0)
 * Any help on this issue would be greatly appreciated.
 * Thanks,
    Ian

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * (@hwk-fr)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/gravity-forms-shortcode-issue/#post-12986708)
 * Hello,
 * Thanks for the feedback. The problem is that you’re already in a global `<form
   >` tag in the “Post Edit” screen (which contain `<input>`: Title, content, ACF
   fields etc…).
 * When you use the Gravity Forms shortcode in your Flexible Content Preview, it
   prints an another `<form>` and `<input>` inside that form, that are not related
   to the current post or ACF. This mix breaks the native “Post Edit” Update form.
   This behavior is not limited to Gravity Forms, it’s the same thing for all forms
   ouput in Layouts Preview Mode (ie: ACF Extended Forms).
 * The solution is to not print the Gravity Forms shortcode HTML (or any other forms)
   in the Preview Mode of the Flexible Content, and instead, print a grey `<div>`
   with a text like “Form” for example.
 * You can disable a specific shortcode in a layout in the preview mode, using the
   following method. Here is a usage example within the Layout `template.php` file:
 *     ```
       // Check if we're in Preview Mode (Admin preview)
       if($is_preview){
   
           // Rewrite the shortcode to print a simple text
           add_shortcode('gravity_form', function(){
   
               echo '<div style="padding:50px 0; text-align:center; background:#f4f4f4;">Gravity Form</div>';
   
           });
   
   
       }
   
       // Normal templating part
       $my_sub_field = get_sub_field('my_sub_field');
       // ...
       ```
   
 * You can also disable the shortcode globally in all previews, in case you have
   multiple WYSIWYG editors in different layouts, by using this hook:
 *     ```
       add_action('acfe/flexible/render/before_template', 'flexible_content_disable_gravity_forms_shortcode', 10, 3);
       function flexible_content_disable_gravity_forms_shortcode($field, $layout, $is_preview){
   
           if($is_preview){
   
               // Rewrite the shortcode to print a simple text
               add_shortcode('gravity_form', function(){
   
                   echo '<div style="padding:50px 0; text-align:center; background:#f4f4f4;">Gravity Form</div>';
   
               });
   
   
           }
   
       }
       ```
   
 * Hope it helps!
 * Regards.
 *  Thread Starter [Ian Chapman](https://wordpress.org/support/users/ianchapman/)
 * (@ianchapman)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/gravity-forms-shortcode-issue/#post-12987432)
 * I figured that was the reason. I just didn’t know if you had a workaround that
   still allowed rendering of the form. But I understand why that is not the case
   with the “form inside a form” issue.
 * We are using multiple WYSIWYG inputs, so I will have to handle it that way. But
   I appreciate offering both solutions.
 * Thanks,
    Ian
 *  Plugin Author [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * (@hwk-fr)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/gravity-forms-shortcode-issue/#post-12987943)
 * Hello,
 * There’s maybe a possible solution with Javascript which consist to automatically
   transform the `<form>` tag output, and `disable` any form input. But I still 
   have to dig in see if I can find an universal & automatic solution.
 * Regards.
 *  Thread Starter [Ian Chapman](https://wordpress.org/support/users/ianchapman/)
 * (@ianchapman)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/gravity-forms-shortcode-issue/#post-12988602)
 * That would be appreciated if there is a JS solution that could eliminate the 
   form tags, so that the form will render as expected, but without any functionality
   when inside the Admin.
 * I’ll use the workaround you provided for now, but would love to see such a feature
   added in the future.
 * Thanks,
    Ian
 *  Thread Starter [Ian Chapman](https://wordpress.org/support/users/ianchapman/)
 * (@ianchapman)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/gravity-forms-shortcode-issue/#post-12988672)
 * Just a small note to anyone who comes across this code snippet – there is a small
   type in the code. The section to modify the Gravity Forms shortcode should be“
   gravityform”, not “gravity_form”.
 *     ```
               add_shortcode('gravityform', function(){
   
                   echo '<div style="padding:50px 0; text-align:center; background:#f4f4f4;">Gravity Form</div>';
   
               });
       ```
   
 * Otherwise the solution is working well for me.
 *  Plugin Author [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * (@hwk-fr)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/gravity-forms-shortcode-issue/#post-12988695)
 * Hello,
 * Yeah, I didn’t know about the shortcode name (I don’t use Gravity Forms), so 
   I just invented that one.
 * For the JS solution, it could leads to some style issue if I delete/transform
   the `<form>` tag, since some CSS rules can target `form .field`. Anyways, I’ll
   try to find some time to work on it, see what I do.
 * Regards.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Gravity Forms Shortcode Issue’ is closed to new replies.

 * ![](https://ps.w.org/acf-extended/assets/icon-256x256.png?rev=2071550)
 * [Advanced Custom Fields: Extended](https://wordpress.org/plugins/acf-extended/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/acf-extended/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/acf-extended/)
 * [Active Topics](https://wordpress.org/support/plugin/acf-extended/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/acf-extended/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/acf-extended/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/gravity-forms-shortcode-issue/#post-12988695)
 * Status: resolved