Skip to content

Instantly share code, notes, and snippets.

@New0
Last active January 27, 2019 15:01
Show Gist options
  • Save New0/43675dc394fef1510eba33668b7dcf5f to your computer and use it in GitHub Desktop.
Save New0/43675dc394fef1510eba33668b7dcf5f to your computer and use it in GitHub Desktop.
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