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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

CheckboxSetField Defaults not working


Go to End


1102 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.