'Boolean' // From customsettings ]; private static $table_name = 'EditableDateField'; /** * @return FieldList */ public function getCMSFields() { $this->beforeUpdateCMSFields(function (FieldList $fields) { $fields->addFieldToTab( 'Root.Main', CheckboxField::create( 'DefaultToToday', _t('SilverStripe\\UserForms\\Model\\EditableFormField.DEFAULTTOTODAY', 'Default to Today?') ), 'RightTitle' ); }); return parent::getCMSFields(); } /** * Return the form field * */ public function getFormField() { $defaultValue = $this->DefaultToToday ? DBDatetime::now()->Format('Y-m-d') : $this->Default; $field = FormField::create($this->Name, $this->EscapedTitle, $defaultValue) ->setFieldHolderTemplate('UserFormsField_holder') ->setTemplate('UserFormsField'); $this->doUpdateFormField($field); return $field; } }