Skip to content
This repository
Browse code

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
Sean Harvey authored March 20, 2012

Showing 1 changed file with 4 additions and 5 deletions. Show diff stats Hide diff stats

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

0 notes on commit b5d4234

Please sign in to comment.
Something went wrong with that request. Please try again.