MINOR: refactored literalfield and formheading to use new mini structure

This commit is contained in:
Will Rossiter 2009-04-27 04:01:06 +00:00
parent 73944fd84f
commit edb703d119
2 changed files with 9 additions and 28 deletions

View File

@ -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;

View File

@ -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>");
}
}
?>