Version: current

     1 <?php
     2 /**
     3  * EditableSiteAgreementField
     4  *
     5  * A user modifiable checkbox on a UserDefinedForm
     6  *
     7  * @package userforms
     8  */
     9
    10 class EditableSiteAgreementField extends EditableFormField {
    11
    12     static $singular_name = 'SiteAgreement Field';
    13
    14     static $plural_name = 'SiteAgreement Fields';
    15
    16     function canCreate($member = null) {
    17         if (SiteConfig::current_site_config()->SiteAgreementField()) {
    18             return true;
    19         }
    20         return false;
    21     }
    22
    23     function onBeforeWrite() {
    24         parent::onBeforeWrite();
    25         $this->Required = 1;
    26     }
    27
    28     function TitleField() {
    29         $field = parent::TitleField();
    30         if (!$field->Value()) {
    31             $field->setValue(_t('EditableSiteAgreementField.DefaultTitleFieldValue'));
    32         }
    33         return $field;
    34     }
    35
    36     public function getFieldConfiguration() {
    37         $fields = parent::getFieldConfiguration();
    38         $fields->removeByName("Fields[$this->ID][CustomSettings][Placeholder]");
    39         $fields->removeByName("Fields[$this->ID][CustomSettings][RightTitle]");
    40         return $fields;
    41     }
    42
    43     public function getFieldValidationOptions() {
    44         return false;
    45     }
    46
    47     public function getFormField() {
    48         if ($field = SiteConfig::current_site_config()->SiteAgreementField()) {
    49             $field->setName($this->Name);
    50             return $field;
    51         }
    52         return false;
    53     }
    54 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -