diff --git a/code/editor/EditableLiteralField.php b/code/editor/EditableLiteralField.php new file mode 100644 index 0000000..18226d2 --- /dev/null +++ b/code/editor/EditableLiteralField.php @@ -0,0 +1,64 @@ + 'Text' + ); + + static $singular_name = 'Literal Field'; + static $plural_name = 'Literal Fields'; + + function __construct( $record = null, $isSingleton = false ) { + + parent::__construct( $record, $isSingleton ); + } + + function ExtraOptions() { + + // eventually replace hard-coded "Fields"? + $baseName = "Fields[$this->ID]"; + + $extraFields = new FieldSet(); + $extraFields->push(new TextareaField($baseName . "[Content]", "Text", 4, 20, $this->Content)); + + return $extraFields; + } + + function populateFromPostData($data) { + + $this->Content = $data['Content']; + parent::populateFromPostData($data); + } + + function getFormField() { + return $this->createField(); + } + + function getFilterField() { + return $this->createField(true); + } + + function createField() { + return new LiteralField("LiteralField[$this->ID]", + "
". $this->Content."
"); + } + /** + * Populates the default fields. + */ + function DefaultField() { + return ""; + } + + function EditSegment() { + return $this->renderWith( $this->class ); + } +} +?> \ No newline at end of file diff --git a/templates/EditableLiteralField.ss b/templates/EditableLiteralField.ss new file mode 100644 index 0000000..d10f909 --- /dev/null +++ b/templates/EditableLiteralField.ss @@ -0,0 +1,20 @@ +
+
+ <% _t('DRAG', 'Drag to rearrange order of fields') %> + <% _t('LITERALFIELD', 'Literal Field') %> + $TitleField + <% _t('MORE', 'More options') %> + <% _t('DELETE', 'Delete this field') %> +
+
+
+ $DefaultField +
+ <% control ExtraOptions %> + $FieldHolder + <% end_control %> +
+ + + +
\ No newline at end of file