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:

Customising the CMS /

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

Insert checkboxField in DataObjectManager

Go to End

2 Posts   572 Views


Community Member, 8 Posts

20 November 2012 at 9:15pm

I have a question!Example:In my table,the status column have boolean style so i want to display it on DataObjectManager as CheckboxField
If status is true,the checkboxfield will check else uncheck
How i display the boolean column as checkboxfield in DataObjectManager or ComplexTableField?


Community Member, 66 Posts

20 November 2012 at 10:48pm

I implemented this in the following way with DataObjectManager.

In your Dataobject $db array

 static $db = array ('Status' = 'Boolean');

Then in the getCMSFields method

 $statusField = new CheckboxField('Status', 'Current Status'); 

It's that simple. Once a boolean value is saved in the Database for Status then the checkbox will be either checked or not checked. You may want to put some validation in place if this data is coming from somewhere other than your CMS, an API for example.