Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Insert checkboxField in DataObjectManager

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

Page: 1
Go to End
Author Topic: 261 Views
  • bubu333
    Community Member
    8 Posts

    Insert checkboxField in DataObjectManager Link to this post

    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?

  • Stef87
    Community Member
    66 Posts

    Re: Insert checkboxField in DataObjectManager Link to this post

    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.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.