Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit b5d4234dfde3de2f96045050a244c122079e6d43 1 parent f85f30a
@halkyon halkyon authored
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.
Please sign in to comment.
Something went wrong with that request. Please try again.