This hook can be used to alter the classes of a field.
quform_field_classes_X_X
This hook is run for a single element.
Example
12
3
4
5
| add_filter('quform_field_classes_1_3', function (array $classes, Quform_Element_Field $element, Quform_Form $form, array $context) { $classes[] = 'my-custom-class'; return $classes; }, 10, 4); |
add_filter('quform_field_classes_1_3', function (array $classes, Quform_Element_Field $element, Quform_Form $form, array $context) { $classes[] = 'my-custom-class'; return $classes; }, 10, 4);
- On line 1, replace the
1_3
with the element unique ID
1
2
3
4
5
6
7 | function my_field_classes(array $classes, Quform_Element_Field $element, Quform_Form $form, array $context) { $classes[] = 'my-custom-class'; return $classes; } add_filter('quform_field_classes_1_3', 'my_field_classes', 10, 4); |
function my_field_classes(array $classes, Quform_Element_Field $element, Quform_Form $form, array $context) { $classes[] = 'my-custom-class'; return $classes; } add_filter('quform_field_classes_1_3', 'my_field_classes', 10, 4);
- On line 7, replace the
1_3
with the element unique ID
Parameters
$classes
–array
– the current classes$element
–Quform_Element_Field
– the element instance$form
–Quform_Form
– the form instance$context
–array
– the context data
quform_field_classes
This hook is run for all elements.
Example
1 2 3 4 5 | add_filter('quform_field_classes', function (array $classes, Quform_Element_Field $element, Quform_Form $form, array $context) { // Custom code return $classes; }, 10, 4); |
add_filter('quform_field_classes', function (array $classes, Quform_Element_Field $element, Quform_Form $form, array $context) { // Custom code return $classes; }, 10, 4);
1 2 3 4 5 6 7 | function my_field_classes(array $classes, Quform_Element_Field $element, Quform_Form $form, array $context) { // Custom code return $classes; } add_filter('quform_field_classes', 'my_field_classes', 10, 4); |
function my_field_classes(array $classes, Quform_Element_Field $element, Quform_Form $form, array $context) { // Custom code return $classes; } add_filter('quform_field_classes', 'my_field_classes', 10, 4);
Parameters
$classes
–array
– the current classes$element
–Quform_Element_Field
– the element instance$form
–Quform_Form
– the form instance$context
–array
– the context data