Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

CheckboxSetField Defaults not working


Reply


390 Views

Avatar
Stef87

Community Member, 66 Posts

3 October 2012 at 2:50am

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.