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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

CheckboxField not set to checked in CMSFields

Go to End

3 Posts   1142 Views


Community Member, 165 Posts

13 November 2012 at 10:20pm

Silverstripe 3

DataObject ScheduleEvent managed in ModelAdmin.

I have $db = array('AllDay" => "Boolean");

and $defaults = array("AllDay" => '1');

When I click new scheduleevent button I get the form for inputting the objects data. However even though it setting the value of the checkbox to 1 it does not set checked param to "checked" This means that on a new object create form the checkbox does not look like it is checked when it should.

How are defaults populated in a create form for a dataobject?

Terry Apodaca

Community Member, 112 Posts

7 May 2015 at 7:46am

I know this is an old topic, but was it ever addressed/fixed? I'm still seeing the same thing your OP says...the checkbox is not being checked in the CMS even with a default => 1 being set.


Community Member, 419 Posts

8 May 2015 at 1:03am

Edited: 08/05/2015 1:04am

Confusion of purposes I think.
Defaults on a DataObject are enacted when it is written for the first time.
The form will just be an empty form, as there's no data to read from yet, thus no checked property.
You must manually default the CheckboxField to checked.

I could be wrong, I have not checked.
But I do not believe the EditForm consults a DataObject's default config when there's no data supplied to populate the form.