Forked from Shelob9/caldera_forms_field_attributes-$field-type.php
Created
November 13, 2018 11:03
-
-
Save espiat/e078454dce3f6600605113639c58cf2b 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