mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
MINOR: refactored literalfield and formheading to use new mini structure
This commit is contained in:
parent
73944fd84f
commit
edb703d119
@ -6,25 +6,15 @@
|
||||
*/
|
||||
class EditableFormHeading extends EditableFormField {
|
||||
|
||||
static $db = array(
|
||||
'Level' => 'Varchar'
|
||||
);
|
||||
|
||||
static $singular_name = 'Form heading';
|
||||
|
||||
static $plural_name = 'Form headings';
|
||||
|
||||
function populateFromPostData($data) {
|
||||
$this->Level = (isset($data['Level'])) ? $data['Level'] : 2;
|
||||
|
||||
parent::populateFromPostData($data);
|
||||
}
|
||||
|
||||
function ExtraOptions() {
|
||||
$levels = array('1','2','3','4','5','6');
|
||||
$default = ($this->Level) ? $this->Level : 2;
|
||||
$levels = array('1' => '1','2' => '2','3' => '3','4' => '4','5' => '5','6' => '6');
|
||||
$level = ($this->getSetting('Level')) ? $this->getSetting('Level') : 3;
|
||||
$extraFields = new FieldSet(
|
||||
new DropdownField("Fields[$this->ID][Level]", _t('EditableFormHeading.LEVEL', 'Select Heading Level'), $levels, $default)
|
||||
new DropdownField("Fields[$this->ID][CustomSettings][Level]", _t('EditableFormHeading.LEVEL', 'Select Heading Level'), $levels, $level)
|
||||
);
|
||||
|
||||
if($this->readonly) {
|
||||
@ -34,7 +24,7 @@ class EditableFormHeading extends EditableFormField {
|
||||
}
|
||||
|
||||
function getFormField() {
|
||||
$labelField = new HeaderField('FormHeadingLabel',$this->Title, $this->Level);
|
||||
$labelField = new HeaderField('FormHeadingLabel',$this->Title, $this->getSetting('Level'));
|
||||
$labelField->addExtraClass('FormHeading');
|
||||
|
||||
return $labelField;
|
||||
|
@ -9,10 +9,6 @@
|
||||
|
||||
class EditableLiteralField extends EditableFormField {
|
||||
|
||||
static $db = array(
|
||||
'Content' => 'Text'
|
||||
);
|
||||
|
||||
static $singular_name = 'HTML Block';
|
||||
|
||||
static $plural_name = 'HTML Blocks';
|
||||
@ -22,19 +18,14 @@ class EditableLiteralField extends EditableFormField {
|
||||
$baseName = "Fields[$this->ID]";
|
||||
|
||||
$extraFields = new FieldSet();
|
||||
$extraFields->push(new TextareaField($baseName . "[Content]", "Text", 4, 20, $this->Content));
|
||||
$extraFields->push(new TextareaField($baseName . "[CustomSettings][Content]", "Text", 4, 20, $this->getSetting('Content')));
|
||||
|
||||
return $extraFields;
|
||||
}
|
||||
|
||||
function populateFromPostData($data) {
|
||||
$this->Content = $data['Content'];
|
||||
parent::populateFromPostData($data);
|
||||
}
|
||||
|
||||
function createField() {
|
||||
function getFormField() {
|
||||
return new LiteralField("LiteralField[$this->ID]",
|
||||
"<div class='field text'><label class='left'>$this->Title</label><div class='middleColumn literalFieldArea'>". $this->Content."</div></div>");
|
||||
"<div class='field text'><label class='left'>$this->Title</label><div class='middleColumn literalFieldArea'>". $this->getSetting('Content') ."</div></div>");
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user