• Resolved cruiseback

    (@cruiseback)


    Tjena Fabian!

    Thanks for this fantastic plugin! I am finally able to kill off Gravity Forms whichc is making our site slow to load because of this gem.

    I have read through the documentation several times, especially this article: https://advancedforms.github.io/filters/forms/af-form-field_attributes/ but for the life of me I cannot make it work, adding an attribute to my <form> field.

    Basically I just want to have “cf-form” added so that I can make this work with Conversational Forms from Space10 (https://space10-community.github.io/conversational-form/).

    Right now I have:
    <form class="af-form acf-form" method="POST" action="CURRENT_URL" id="form_5a2fb917a49ce">

    And I would like to end up with:
    <form cf-form class="af-form acf-form" method="POST" action="CURRENT_URL" id="form_5a2fb917a49ce">

    Can you help me with the relevant code to get this done?

    Thanks again for a great plugin!

    CB

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hall?!

    Super glad to hear you’re enjoying AF. I made the plugin to replace the awful Gravity Forms in my day job and I’m happy others are able to as well.

    The af/form/field_attributes is used to add attributes to individual fields of a form and not the form in itself.

    Luckily there is actually a corresponding filter for the form element as well but I have yet to document it. The filter is af/form/attributes and can be used something like this (untested):

    
    function add_form_class($atts, $form, $args) {
      $atts['cf-form'] = '';
      return $atts;
    }
    add_filter( 'af/form/attributes', 'add_form_class', 10, 3 );
    

    I hope it works!

    Thread Starter cruiseback

    (@cruiseback)

    Tackar! That worked a treat, GF have now been disabled, and what a joyful moment that was ??

    CB

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Glad to hear! Feel free to reach out if you have any other questions or problems.

    God forts?ttning!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add new attribute to field’ is closed to new replies.