class MyObject extends \DataObject { // define fields and relations function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', new TextField('MyField', 'My Field')); return $fields; } }
class MyObject extends \DataObject { // define fields and relations } $fields = MyObject::create()->getCMSFields(); $fields->addFieldToTab('Root.Main', new TextField('MyField', 'My Field')); echo $fields;In this example, we have created a new instance of the MyObject class and added a custom CMS field to its CMS fields array. We then output the fields array to the screen. Package/library: Silverstripe (a popular PHP CMS framework) makes use of PHP DataObject library for its ORM functionality.