Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/869d0ebb94b017ca690ed70c5aa7431a to your computer and use it in GitHub Desktop.
Save Shelob9/869d0ebb94b017ca690ed70c5aa7431a to your computer and use it in GitHub Desktop.
Set a custom validation error message for one Caldera Forms field See: https://calderaforms.com/doc/caldera_forms_field_attributes/
<?php
/**
* Set a custom validation error message for one Caldera Forms field
*/
add_filter( 'caldera_forms_field_attributes', function($attrs, $field){
//IMPORTANT - Change your field ID
if ( 'fld1234' === $field[ 'ID'] ) {
$attrs[ 'data-parsley-error-message' ] = 'You must enter a number between 42 and 88';
}
return $attrs;
}, 10, 2 );
@amsgator
Copy link

It would appear the checkbox does not accept data-parsley-error-message as an attribute. Even with this filter it's still rendering parsley-required.

It also appears substituting $attrs[ 'parsley-required' ] doesn't help.

@TradeFidotcom
Copy link

Hello, is there list of attrs which can be set using filter caldera_forms_field_attributes. Also which source file govern just for reference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment