Skip to content

Instantly share code, notes, and snippets.

@Shelob9

Shelob9/multi-checkbox.php

Last active Jan 13, 2021
Embed
What would you like to do?
<?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

This comment has been minimized.

Copy link

@NoemieDu76 NoemieDu76 commented Jan 13, 2021

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