2008-09-29 05:18:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Allows an editor to insert a generic heading into a field
|
2009-04-17 04:26:40 +02:00
|
|
|
*
|
2012-04-14 08:36:50 +02:00
|
|
|
* @package userforms
|
2008-09-29 05:18:23 +02:00
|
|
|
*/
|
2009-12-07 03:04:20 +01:00
|
|
|
|
2008-09-29 05:18:23 +02:00
|
|
|
class EditableFormHeading extends EditableFormField {
|
2009-04-27 06:01:06 +02:00
|
|
|
|
2013-04-03 03:34:43 +02:00
|
|
|
private static $singular_name = 'Heading';
|
2009-04-17 04:26:40 +02:00
|
|
|
|
2013-04-03 03:34:43 +02:00
|
|
|
private static $plural_name = 'Headings';
|
2015-07-24 04:37:48 +02:00
|
|
|
|
|
|
|
private static $db = array(
|
|
|
|
'Level' => 'Int(3)', // From CustomSettings
|
|
|
|
'HideFromReports' => 'Boolean(0)' // from CustomSettings
|
|
|
|
);
|
|
|
|
|
|
|
|
private static $defaults = array(
|
|
|
|
'Level' => 3,
|
|
|
|
'HideFromReports' => false
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return FieldList
|
|
|
|
*/
|
|
|
|
public function getCMSFields() {
|
|
|
|
$fields = parent::getCMSFields();
|
|
|
|
|
|
|
|
$fields->removeByName('Default');
|
|
|
|
$fields->removeByName('Validation');
|
|
|
|
|
2012-04-14 08:36:50 +02:00
|
|
|
$levels = array(
|
|
|
|
'1' => '1',
|
|
|
|
'2' => '2',
|
|
|
|
'3' => '3',
|
|
|
|
'4' => '4',
|
|
|
|
'5' => '5',
|
|
|
|
'6' => '6'
|
|
|
|
);
|
|
|
|
|
2015-07-24 04:37:48 +02:00
|
|
|
$fields->addFieldsToTab('Root.Main', array(
|
|
|
|
DropdownField::create(
|
|
|
|
'Level',
|
|
|
|
_t('EditableFormHeading.LEVEL', 'Select Heading Level'),
|
|
|
|
$levels
|
|
|
|
),
|
|
|
|
CheckboxField::create(
|
|
|
|
'HideFromReports',
|
|
|
|
_t('EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?')
|
2012-09-10 06:07:52 +02:00
|
|
|
)
|
2015-07-24 04:37:48 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
return $fields;
|
2009-04-21 05:44:13 +02:00
|
|
|
}
|
2012-09-10 06:07:52 +02:00
|
|
|
|
2012-05-04 03:39:08 +02:00
|
|
|
public function getFormField() {
|
2015-07-24 04:37:48 +02:00
|
|
|
$labelField = new HeaderField($this->Name, $this->Title, $this->Level);
|
2008-11-01 16:32:36 +01:00
|
|
|
$labelField->addExtraClass('FormHeading');
|
|
|
|
return $labelField;
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
|
|
|
|
2012-05-04 03:39:08 +02:00
|
|
|
public function showInReports() {
|
2015-07-24 04:37:48 +02:00
|
|
|
return !$this->HideFromReports;
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
2009-05-06 05:34:40 +02:00
|
|
|
|
2012-05-04 03:39:08 +02:00
|
|
|
public function getFieldValidationOptions() {
|
2009-05-06 05:34:40 +02:00
|
|
|
return false;
|
|
|
|
}
|
2012-09-10 06:07:52 +02:00
|
|
|
}
|