Hi!
I’m not quite sure what you’re aiming to achieve. Are you trying to add a class to a field or are you trying to edit the attributes of a specific field?
Thanks for reaching out!
actually both, I just want to see a more detailed real life example of the above function, for instance how can I address a specific field:
$field =’myfield’;
return $field?
I see!
You can adress a specific field by checking the name or key of $form. Something like this:
function filter_field_attributes( $attributes, $field, $form, $args ) {
// Check field name
if ( 'field_name' != $field['name'] ) {
return $attributes;
}
// Perform changes
$attributes[‘id’] = ‘form-id’;
return $attributes;
}
This will only apply to the field with name field_name. You can do similar things if you instead want to address fields based on their field key or type.
Hope this helps!
Hi @fabianlindfors —
Thanks for such a wonderful plugin!
I am also a little confused on how to target specific field inputs and add classes to them. Would you mind going into a little more detail on how that works?
Kindly-
-
This reply was modified 7 years, 4 months ago by
joshwhite.