Home Forums Pre-purchase Questions acf_form and AMP


acf_form and AMP

  • I just stumbled upon Advanced Custom Fields and I am in love with all of the advanced features this plugin has. I will definitely be getting the pro lifetime license.

    My question has to do with acf_form and the official AMP plugin. Does the front-end forms this feature create load js files on the pages they are embedded on? Also, do the forms contain the action-xhr attribute when the form method is post as per the AMP guidelines? if not, is this something I could easily add?

  • 1) Yes, it loads JS, all of the code required to make the fields work is loaded.

    2) No it does not and does not and ACF does not support natively submitting forms using AJAX

  • In order to do this you would need to build your own form and your own form processor that can be called using ajax in WP that would properly save all the submitted values and not use acf_form() at all.

  • Thanks, @hube2,

    in regards to your answer to #1, does it load the JS site-wide (aka on every page) or on just the page where the acf_form() is added?

    I have looked into other form software and some like Toolset Forms loads JS across the whole site, while others like Gravity Forms only loads the JS on the pages where a form is added.

    If its like Gravity Forms, I can still use acf_form() and just set those specific pages to not use AMP. If it loads site-wide, however, I can’t use it as I want the majority of the website to validate as AMP.

  • This depends on how you implement it. The function acf_form_head() call that is required needs to be before any html is output. Calling this function is what causes all of the JS to be loaded and what causes the form to be processed when submitted.

    If you put this in your header.php file then it will be loaded site wide.

    If this is put in the template file for the page just before get_header() then it will be loaded on any page using that template.

    You can have it loaded on just pages that have use acf_form() by creating a page template that will only be used for these pages.

    There are potentially other ways that this can be done as well but each gets a little more complicated.

    For example, you could have an init action

    add_action('init', 'some_function_name_here');
    some_function_name_here() {
      if (/*some condition*/) {
  • Perfect @hube2 that lets me know what I need!

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

The topic ‘acf_form and AMP’ is closed to new replies.