I guess a little trial and error is the thing… this seems to work if someone wants to confirm or tell of a way to use “default option” in the interface?
add_filter( 'caldera_forms_render_get_field', function( $field ) {
if ( 'lightsaber_color' == $field[ 'slug' ] ) {
//error_log(print_r($field,true));
$data = array('red' => 'Red', 'orange' => 'Orange', 'yellow' => 'Yellow', 'green' => 'Green', 'blue' => 'Blue', 'purple' => 'Purple', 'pink' => 'Pink', 'black' => 'Black');
//error_log(print_r($data,true));
foreach ($data AS $val => $label) {
$field['config']['option'][$val] = array(
'value' => $val,
'label' => $label,
);
}
//set a default?
//$field['config']['default'] = 'pink';
//set a lot of defaults?
$field['config']['default'] = array('red', 'pink');
}
return $field;
});
Thanks for using Caldera Forms. We do not support multiple defaults for any field type at this time. We are working on adding support, hopefully for 1.6.0, but that might get pushed to 1.6.1
You can follow here:
https://github.com/CalderaWP/Caldera-Forms/pull/2322
Thanks, it is working great through code, and that’s plenty good enough for me 🙂
PS > I’m using the same logic of $field[‘config’][‘default’] = array() as on github there. I’ll try to look there before posting from now on!