5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 908 Views |
-
TreeDropdownField doesn't save selection - SS2.4

13 July 2010 at 1:14pm
Howdy
I have added the following code to create a selectable drop down tree of CMS pages for one of my page types:
class ArchivePage extends Page {
static $db = array(
);static $has_one = array(
'ArchivePageID' => 'SiteTree',
);function getCMSFields(){
$tree = new TreeDropdownField('ArchivePageID', 'Choose a Parent page to display an archive of the Child pages', 'SiteTree');
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', $tree, 'Content');
return $fields;
}}
This displays a dropdown selection of all of the pages in the website but when I select a page and click "Save" the box resets to just reading "(Choose)".
I'm sure I'm just making a simple mistake but I've been wading through the documentation and forums and haven't found anything that works.
Hopefully someone can let me know what I'm missing.
Cheers
Tama -
Re: TreeDropdownField doesn't save selection - SS2.4

13 July 2010 at 2:10pm
Update: I changed "ArchivePageID" to "ArchiveParent" to prevent any conflicts and it's still not working.
-
Re: TreeDropdownField doesn't save selection - SS2.4

14 July 2010 at 9:07am
OK, sorted it out - thanks Mateusz.
You have to remove ID from $has_one:
static $has_one = array(
'ArchivePage' => 'SiteTree',
);But still include it in the getCMSFields:
function getCMSFields(){
$tree = new TreeDropdownField('ArchivePageID', 'Choose a Parent page to display an archive of the Child pages', 'SiteTree');
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', $tree, 'Content');return $fields;
}
| 908 Views | ||
|
Page:
1
|
Go to Top |

