Created
February 20, 2017 19:15
-
-
Save Shelob9/3eed7e9d43c39655dd65e782daefbf82 to your computer and use it in GitHub Desktop.
Change maxlength for Caldera Forms text and text input or max for number fields See: https://calderaforms.com/doc/caldera_forms_field_attributes/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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