Support » Plugin: WP2Static » Form tag attributes not deploying to Netlify

  • Resolved jweston

    (@jweston)


    I’m using a Gravity Forms filter to add support for Netlify Forms. Here’s my code:

    //Add Netflify tag to GForms
    add_filter( 'gform_form_tag', 'form_tag_netlify', 10, 2 );
    function form_tag_netlify( $form_tag, $form ) {
        $form_name = $form['title'];
        $form_tag = str_replace( "<form ", "<form name='{$form_name}' data-netlify='true'", $form_tag );
        return $form_tag;
    }

    This works and correctly adds the tag data-netlify='true' to my Gravity Forms <form> tag output; however, when I deploy directly from WordPress to Netlify, the data-netlify attribute is lost (This also happens if I just try adding netlify). Weirdly enough, the name attribute added by my code is carrying over.

    I am pretty sure this is not an issue on Netlify’s end as everything works as expected if I export my static site as a .zip and upload it through Netlify’s dashboard, and I am pretty sure it’s not a Gravity Forms issue since the code works as expected on my WP server.

    Reference:
    https://www.netlify.com/docs/form-handling/
    https://docs.gravityforms.com/gform_form_tag/

    • This topic was modified 2 years, 2 months ago by jweston.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Leon

    (@leonstafford)

    Hi @jweston,

    Interesting, indeed. Could you please try deleting the Deploy Cache in the Advanced tab and try again?

    As you mentioned that a ZIP works but not the Netlify API deploy, it sounds like it may be a caching issue…

    Failing that, please turn on Debug Mode (Advanced tab), re-run and email me the report: leon@wp2static.com

    Cheers,

    Leon

    Plugin Author Leon

    (@leonstafford)

    Hi @jweston,

    Just following up on this. I think it’s expected behaviour now, that Netlify strips this out when they build your site.

    ie, I’m using a Netlify form on https://wp2static.com, with the same custom attribute as you and forms are being delivered fine. If you inspect the source, you’ll see there’s no custom attribute in the deployed site.

    If it’s a new Netlify site, be sure to enable notifications for the form in the site settings. It’s also fastest to check the form’s been submitted by checking the responses collected within Netlify. I caught myself on this issue last week, thinking they weren’t being delivered due to the form markup, then realized I hadn’t enabled the email notifications!

    Please let me know if any issues persisting.

    Cheers,

    Leon

    Thread Starter jweston

    (@jweston)

    Sorry for not following up on this, thanks for helping out! This appeared to solve the issue for me.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Form tag attributes not deploying to Netlify’ is closed to new replies.