Version: current

     1 <?php
     2 /**
     3  * Allows an editor to insert a generic heading into a field
     4  *
     5  * @package userforms
     6  */
     7
     8 class EditableFormHeading extends EditableFormField {
     9
    10     static $singular_name = 'Heading';
    11
    12     static $plural_name = 'Headings';
    13
    14     function getFieldConfiguration() {
    15         $levels = array(
    16             '1' => '1',
    17             '2' => '2',
    18             '3' => '3',
    19             '4' => '4',
    20             '5' => '5',
    21             '6' => '6'
    22         );
    23
    24         $level = ($this->getSetting('Level')) ? $this->getSetting('Level') : 3;
    25         $label = _t('EditableFormHeading.LEVEL', 'Select Heading Level');
    26
    27         $options = parent::getFieldConfiguration();
    28         $options->removeByName("Fields[$this->ID][CustomSettings][Placeholder]");
    29         $options->removeByName("Fields[$this->ID][CustomSettings][RightTitle]");
    30
    31         $options->push(
    32             new DropdownField($this->getSettingName("Level"), $label, $levels, $level)
    33         );
    34
    35         if($this->readonly) {
    36             $extraFields = $options->makeReadonly();
    37         }
    38
    39         return $options;
    40     }
    41
    42     function getFormField() {
    43         $labelField = new HeaderField($this->Name,$this->Title, $this->getSetting('Level'));
    44         $labelField->addExtraClass('FormHeading');
    45
    46         return $labelField;
    47     }
    48
    49     function showInReports() {
    50         return true;
    51     }
    52
    53     function getFieldValidationOptions() {
    54         return false;
    55     }
    56 }

[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. -