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.

Customising the CMS /

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

Insert checkboxField in DataObjectManager


Go to End


2 Posts   855 Views

Avatar
bubu333

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?

Avatar
Stef87

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.