21491 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1012 Views |
-
DataObjectDecorator Question

11 March 2011 at 12:40pm Last edited: 11 March 2011 1:12pm
Salutations,
I am trying to use the DataObjectDecorator to add some fields to the UserDefinedForm. I need to add a textbox for a Sidebar. When I use this code in my /code/ directory
<?php
class CustomForm extends DataObjectDecorator{
function extraField(){
return array(
'db' => array(
'Sidebar' => 'HTMLText'
),
'has_one' => array(
),
);
}
public function updateCMSFields(FieldSet $fields) {
$fields->push(new HTMLEditorField('Sidebar','Sidebar'));
}
}
?>As well, I added the appropriate code onto the _config.php.
When I go into the CMS, the Sidebar field is anchored to the bottom of my editor window. It seems like the CMS is adding the field, but not into the Content->Main fieldset.
How can I add this field to a different tab, or change it's order so it's not anchored to the bottom?
-
Re: DataObjectDecorator Question

11 March 2011 at 3:19pm
perhaps try:
public function updateCMSFields(FieldSet $fields) {
$fields->addFieldToTab('Root.Content.Main', new HTMLEditorField('Sidebar','Sidebar'));
} -
Re: DataObjectDecorator Question

12 March 2011 at 11:51am
Thanks Stu,
That worked - however I can't get the new field to save any data. When I add my data, and hit the "Save and Publish" button, the page refreshes and my field is blank. Any idea what's wrong?
-
Re: DataObjectDecorator Question

15 March 2011 at 6:47am
Try using extraStatics() instead of extraFields():
function extraStatics() {
return array(
'db' => array(
"Sidebar" => "HTMLText",
)
);
}Then do a /dev/build/?flush=1...
| 1012 Views | ||
|
Page:
1
|
Go to Top |

