Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

amsgator commented Jun 28, 2018

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

TradeFidotcom commented Nov 3, 2020

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