• Resolved Furo

    (@furocan)


    Hey!

    I think I just found a bug.
    The documentation says the filter “af/field/before_render” has 3 variations:
    add_filter( ‘af/field/before_render’, ‘modify_field’, 10, 3 );
    add_filter( ‘af/field/before_render/name=FIELD_NAME’, ‘modify_field’, 10, 3 );
    add_filter( ‘af/field/before_render/key=FIELD_KEY’, ‘modify_field’, 10, 3 )

    But in the “form-rendering.php” there are these 3 types:
    ‘af/field/before_render’
    ‘af/field/before_render/id=’ . $form[‘post_id’]
    ‘af/field/before_render/key=’ . $form[‘key’]

    So it’s not possible to add the filter to a certain field.

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

    (@fabianlindfors)

    This is certainly a bug!

    The documentation is how the action should work. I’m not sure how to go about adjusting this as I’m afraid of breaking other peoples’ existing code. I’m going to think about it but until then you can work around it. Here’s how to target a specific field by name for example:

    function add_before_field( $field ) {
      if ( 'FIELD_NAME' != $field['name'] ) {
        return;
      }
    
      echo "BEFORE FIELD"; 
    }
    add_filter( ‘af/field/before_render’, ‘ add_before_field’, 10, 1 );
    
    Thread Starter Furo

    (@furocan)

    Thanks for your fast response.

    I understand your concerns and realize a solution similiar to your example so it works for now.

    Besides the Plugin is really great!

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Thank you! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘field/before_render doesn’t accept field name’ is closed to new replies.