quform_field_attributes

This hook can be used to alter the attributes of a field.

quform_field_attributes_X_X

This hook is run for a single element.

Example

12
3
4
5
add_filter('quform_field_attributes_1_3', function (array $attributes, Quform_Element_Field $element, Quform_Form $form, array $context) {    $attributes['placeholder'] = 'Enter your name';
 
    return $attributes;
}, 10, 4);
add_filter('quform_field_attributes_1_3', function (array $attributes, Quform_Element_Field $element, Quform_Form $form, array $context) {
    $attributes['placeholder'] = 'Enter your name';

    return $attributes;
}, 10, 4);
  • On line 1, replace the 1_3 with the element unique ID
1
2
3
4
5
6
7
function my_field_attributes(array $attributes, Quform_Element_Field $element, Quform_Form $form, array $context)
{
    $attributes['placeholder'] = 'Enter your name';
 
    return $attributes;
}
add_filter('quform_field_attributes_1_3', 'my_field_attributes', 10, 4);
function my_field_attributes(array $attributes, Quform_Element_Field $element, Quform_Form $form, array $context)
{
    $attributes['placeholder'] = 'Enter your name';

    return $attributes;
}
add_filter('quform_field_attributes_1_3', 'my_field_attributes', 10, 4);
  • On line 7, replace the 1_3 with the element unique ID

Parameters

  • $attributesarray – the current attributes
  • $elementQuform_Element_Field – the element instance
  • $formQuform_Form – the form instance
  • $contextarray – the context data

quform_field_attributes

This hook is run for all elements.

Example

1
2
3
4
5
add_filter('quform_field_attributes', function (array $attributes, Quform_Element_Field $element, Quform_Form $form, array $context) {
    // Custom code
 
    return $attributes;
}, 10, 4);
add_filter('quform_field_attributes', function (array $attributes, Quform_Element_Field $element, Quform_Form $form, array $context) {
    // Custom code

    return $attributes;
}, 10, 4);
1
2
3
4
5
6
7
function my_field_attributes(array $attributes, Quform_Element_Field $element, Quform_Form $form, array $context)
{
    // Custom code
 
    return $attributes;
}
add_filter('quform_field_attributes', 'my_field_attributes', 10, 4);
function my_field_attributes(array $attributes, Quform_Element_Field $element, Quform_Form $form, array $context)
{
    // Custom code

    return $attributes;
}
add_filter('quform_field_attributes', 'my_field_attributes', 10, 4);

Parameters

  • $attributesarray – the current attributes
  • $elementQuform_Element_Field – the element instance
  • $formQuform_Form – the form instance
  • $contextarray – the context data

Still having trouble? Head over to the forums.

Forums