Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change maxlength for Caldera Forms text and text input or max for number fields See: https://calderaforms.com/doc/caldera_forms_field_attributes/
<?php
/**
* Set a max length attribute for all paragraph fields in Caldera Forms
*/
add_filter( 'caldera_forms_field_attributes-paragraph', function( $attrs ){
$attrs[ 'maxlength' ] = 255;
return $attrs;
});
<?php
add_filter( 'caldera_forms_field_attributes', function( $attrs, $field, $form ){
$type = Caldera_Forms_Field_Util::get_type( $field, $form );
if( 'text' == $type ){
$attrs[ 'maxlength' ] = 255;
}elseif( 'paragraph' == $type ){
$attrs[ 'maxlength' ] = 512;
}elseif( 'number' == $type ){
$attrs[ 'max' ] = 42;
}
return $attrs;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.