caldera_forms_render_form_attributes

Mount Fiji In The Clouds

This filter modifies the HTML attributes that are added to the form element for a Caldera Form.

These are the default arguments, at the time this filter runs,

  • “method” – Default is “POST”
  • “enctype” – Default is “multipart/form-data”
  • “id” – This is the form ID, an underscore, and the current form count. If you change this basically everything will break.
  • “aria-label” – Default is the name of the form. Added in 1.5.8.

Parameters:

  • $form_attributes – An array of attributes to output on form element
  • $form – The form configuration as an array.

Important Notes:

  • Before 1.5.8, a “role” attribute with the value of “form” was used. This was removed as it is redundant.
  • Do not escape attributes. They will be escaped later.
  • If your forms are set to submit via AJAX, the default setting, then additional arguments are added by the function cf_ajax_setatts, which is hooked to this filter with the priority of 10. Therefore, you should use a priority of 11 or higher.

 

Change Role Attribute For Form Element

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