Support » Plugin: Advanced Custom Fields: Extended » Flexible Content – Not saving changes after update

  • Resolved rose18

    (@rose18)


    We have a site that have these plugins installed: Advanced Custom Fields PRO (Version 5.11.4) + Advanced Custom Fields: Extended (Version 0.8.8.6)
    I am using Flexible Content type to create different layouts for the pages.
    Also, I have these enabled:
    – Advanced Flexible Content
    – Dynamic Render
    – Dynamic Preview

    When we try to save a page with the changes, it doesn’t save it after I click on the ‘Update’ button. It reverts back to the old text.
    Say if a changed a word from one of the layout (I am using ACF Flexible content), once I hit the ‘Update’ button to save the change, it doesn’t save it. It keeps the old text.

    When I have Dynamic Render and Dynamic Preview disabled, it doesn’t seem to have the issue, but once I enable both, the issue starts again.

    I really would like to keep the Dynamic Preview feature. Can this be fixed?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author hwk-fr

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    I just checked the feature, and it works correctly. Few weeks ago you posted a topic about the Flexible Content Dynamic Preview, asking a question about a custom stylesheet enqueue, which suggests that the feature was working on your setup back then.

    Maybe you have some compatibility issues with an another field which has the same name, and erase the Flexible Content values during the saving process?

    I would recommend to try to create a new “Test Field Group” with a “Test Flexible Content” (using an unique name), and create a “Test layout”. Then display that Flexible Content on a new “Test Page”, see if that fix the issue.

    If the problem persists, maybe it comes from a plugin or a custom code in the theme. You can try to disable your plugins one-by-one until you find which one is causing it. The last resort is to switch back to the native WordPress Twenty Twenty One theme, in order to make sure you don’t have custom code that break the saving process.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter rose18

    (@rose18)

    Thank you for your response!
    I believe I know why it’s not saving the changes.
    For pages that uses the Flexible content and has Dynamic Preview enabled, it seems to be not saving the changes when the content has ajax. I have created a ‘Regular Text’ layout using Flexible content and when the content area (using a WYSIWYG editor field) has a gravity form (that uses ajax) or other embedded elements that uses ajax, it doesn’t save the changes. When I removed the gravity form shortcode and other elements that contains ajax from the content area, it doesn’t have the update issue.

    Is there a way to fix the issue? or is there a way to not display the dynamic preview in the admin if the content contains AJAX and just replace it with a text message? Maybe displaying “This content cannot be previewed in the admin because it’s using AJAX”.

    Thank you!

    Plugin Author hwk-fr

    (@hwk-fr)

    Oh okay I understand.

    The problem is that you render a Gravity Form in the preview. Since you’re already in a <form> on the Post Edit screen, when you render Gravity form it will print an another <form> inside it and will add new inputs from the form.

    This breaks the the Post Edit saving process since HTML specifications doesn’t allow multiple <form> one in each others, and the <input> of the gravity form mix up with the data of the Post Edit screen.

    You can read more about this problem on this other topic: Gravity Forms Shortcode Issue

    The solution is to rewrite the [gravityform] shortcode when you’re inside a Dynamic Preview, and display a placeholder instead. That hook should do the trick:

    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('gravityform', function(){
                
                echo '<div style="padding:50px 0; text-align:center; background:#f4f4f4;">Gravity Form</div>';
                
            });
    
            
        }
        
    }
    

    Just make sure that the shortcode is [gravityform], I’m not a Gravity Form user, so I don’t really know how it’s called. You’ll find more information about that acfe/flexible/render/before_template hook in the documentation.

    Note that the ACF Extended Forms aren’t concerned by that issue and are correctly rendered in the Dynamic Preview. Unfortunately, the same thing cannot be automatically achieved with third party forms solutions, since each one of them are quite unique.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter rose18

    (@rose18)

    Thank you so much!

    The code you provided works!!

    Plugin Author hwk-fr

    (@hwk-fr)

    Great to hear!

    If you enjoy this plugin and its support, feel free to submit a review. It always helps and it’s much appreciated 🙂

    Have a nice day!

    Regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.