Browse files

MINOR Correct DropdownField class documentation to include a proper

example using DataList and non-deprecated way of setting the empty value
and string
  • Loading branch information...
1 parent f85f30a commit b5d4234dfde3de2f96045050a244c122079e6d43 @halkyon halkyon committed Mar 20, 2012
Showing with 4 additions and 5 deletions.
  1. +4 −5 forms/DropdownField.php
View
9 forms/DropdownField.php
@@ -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.

0 comments on commit b5d4234

Please sign in to comment.