Reputation: 556
Hi I'm using SilverStripe 2.4.7
I am generating around 250+ checkboxes, using a DataObjectSet of DataObjects, and want all of them to be checked by default. I tried passing the same array that populates the checkboxsetfield to the setDefaultItems method like so...
$checkBox->setDefaultItems( $values );
but that didn't work. I'm completely stumped as I can't find anything else that even hints at how to do this and I'm getting desperate.
I just keep getting this error.
in_array() expects parameter 2 to be array, object given
Thank you.
Upvotes: 0
Views: 1431
Reputation: 6409
It sounds like you are passing an associative array with key/value pairs, when what it's after is an indexed array, with only the key (checkbox value).
Try
$checkBox->setDefaultItems( array_keys($values) );
Upvotes: 1