Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active January 13, 2021 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/cc9abfbb1998d0ac023f974552681d85 to your computer and use it in GitHub Desktop.
Save Shelob9/cc9abfbb1998d0ac023f974552681d85 to your computer and use it in GitHub Desktop.
<?php
/**
* Set a Caldera Forms checkbox field to have mutltiple defaults selected
*
* Requires: Caldera Forms 1.6 or later
*
* Important: This only works with checkox fields
*/
add_filter( 'caldera_forms_render_get_field', function( $field, $form ){
if( 'fld_9641225' === $field[ 'ID' ] ){
$field[ 'config' ][ 'default' ] = array(
'Yes', 'No'
);
}
return $field;
}, 10, 2 );
@NoemieDu76
Copy link

Hello,

I'm very interested by this solution, but infortunatly I don't manage to make it works.

I've put this code in the functions.php in my child theme + I've changed the 'fld_9641225' by the actual ID of my checkbox file.

Nothing change, I'm afraid I can't find why by my own... Your help would be a lot appreciated ^^

Thks,

Noémie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment