Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Caldera Forms. Add disabled attribute to options in Checkbox, Dropdown and Select 2 fields
<?php
//Example of how to use a Disabled attribute for options in Checkbox, dropdown or select 2 fields
add_filter( 'caldera_forms_render_get_field', function( $field ) {
if( 'fld_4425558' === $field[ 'ID' ] ){ //Field ID => 'fld_4425558'
$field[ 'config' ][ 'option' ]['opt1996332']['disabled'] = true; // Option ID => 'opt1996332'
} else if( 'fld_7668742' === $field[ 'ID' ] ){ //Field ID => 'fld_7668742'
$field[ 'config' ][ 'option' ]['opt3137985']['disabled'] = true; // Option ID => 'opt3137985'
} else if( 'fld_381620' === $field[ 'ID' ] ){ //Field ID => 'fld_381620'
$field[ 'config' ][ 'option' ]['opt1172954']['disabled'] = true; // Option ID => 'opt1172954'
}
return $field;
});
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.