MINOR Correct DropdownField class documentation to include a proper

example using DataList and non-deprecated way of setting the empty value
and string
This commit is contained in:
Sean Harvey 2012-03-20 15:47:22 +13:00
parent f85f30ac61
commit b5d4234dfd

View File

@ -13,11 +13,10 @@
*
* public function getCMSFields() {
* $fields = parent::getCMSFields();
* $galleries = DataObject::get('Gallery');
* if ($galleries) {
* $galleries = $galleries->toDropdownMap('ID', 'Title', '(Select one)', true);
* }
* $fields->addFieldToTab('Root.Content', new DropdownField('GalleryID', 'Gallery', $galleries), 'Content');
* $field = new DropdownField('GalleryID', 'Gallery', DataList::create('Gallery')->map('ID', 'Title'));
* $field->setHasEmptyDefault(true);
* $field->setEmptyString('(Select one)');
* $fields->addFieldToTab('Root.Content', $field, 'Content');
* </code>
*
* As you see, you need to put "GalleryID", rather than "Gallery" here.