3063 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1212 Views |
-
Using DropdownField in the admin

5 December 2009 at 12:37am Last edited: 5 December 2009 12:38am
Hi
I created some page decoration that one of its field is other page.
I use the DropdownField to allow the selection of the page. The problem is that the DropdownField indeed display the pages, but it does not save the selected one.class MyDecorator extends DataObjectDecorator {
function extraStatics() {
return array(
'db' => array(
"AAA" => "Varchar(255)",
),
'has_one' => array(
"MyPage" => "Page",
),
);
}public function updateCMSFields(FieldSet &$fields) {
$fields->addFieldToTab("Root.Content.PageHolder", new TextField("AAA", "My AAA", "default"));
$fields->addFieldToTab("Root.Content.PageHolder", new DropdownField('MyPage', 'My Page', Dataobject::get("Page")->toDropdownMap('ID','Title','[From Parent]')));}
...
}
The AAA (which I just add for test if it works) is saved as it should.
In The MyPage the list of the pages is display correctly, but the selected value isnt saved).any ideas,
Thanks
Rotem. -
Re: Using DropdownField in the admin

5 December 2009 at 2:02am
The relation is stored in the database with MYPageID.
This should work:
$fields->addFieldToTab("Root.Content.PageHolder", new DropdownField('MyPageID', 'My Page', Dataobject::get("Page")->toDropdownMap('ID','Title','[From Parent]')));
-
Re: Using DropdownField in the admin

5 December 2009 at 5:12am
thanks, that works now.
Other problem I have now is that for the first time I save a Page I must select MyPage field for the save to success (and cant choose the "[from parent]" one. After the first save, it is possible to select the "[from parent]" one.
This mean that for each page the user need to select the other than "[from parent]" for the first page, and then if he want the default he should select it again and save again.How can I fix that?
thanks,
Rotem. -
Re: Using DropdownField in the admin

5 December 2009 at 12:12pm
Ok, I guess thats happens because of DB mess I made while learning build the module by Try & Error (and I had a lot of Errors...
)
I deleted all the table and reinstall it, and all seems to work now.thanks,
Rotem.
| 1212 Views | ||
|
Page:
1
|
Go to Top |


