Caldera Forms logo and name


This filter was added in Caldera Forms 1.5.0

This filter can be used to add, remove or modify HTML attributes for input elements.

The parameter exposed by this filter is an array of attributes that are used for the HTML inputs of Caldera Forms. Each of these attributes will be passed through esc_attr(). Do not add additional escaping.

You can use this filter to add an attribute to a field type’s input:

You can also add to an existing attribute. For example, to add an additional class to all text inputs:

More Examples

Set Maximum Value For Caldera Forms Number Fields

Because this filter exposes form and field configuration you can target field’s by type, or field ID or form ID. All three options are shown here for adding a maximum argument for number fields:

Limit Total Characters For A Paragraph Field

Paragraph fields use textarea elements. You can set the maximum allowed characters using the maxlength attribute.

Set The Date Range For Caldera Forms Date Fields

Many of our fields use data attributes for configuration, for example, the date picker field can change its behaviour by adding data attributes to the input. Here is how you can use this filter to set the date picker field to have Saturday and Sunday disabled:

Dynamic Filters

There is also a dynamically named version of this filter for each field type. For example, to modify all paragraph fields, you would use caldera_forms_field_attributes-paragraph or for all hidden fields, you would use caldera_forms_field_attributes-hidden. See this example.

Set a Custom Validation Error Message for One Caldera Forms Field

Where Does This Code Go?

When using WordPress hooks to customize Caldera Forms or other plugins you should not modify the plugin files, or you will lose your changes when you update the plugin. Instead you should create a small plugin to hold the custom code. It's easy, learn how here.

Technically you can add the custom code to your theme's functions.php, but then you will not be able to change your theme and keep these customizations.

Learn More