mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 21:29:23 +02:00
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:
parent
f85f30ac61
commit
b5d4234dfd
@ -13,11 +13,10 @@
|
|||||||
*
|
*
|
||||||
* public function getCMSFields() {
|
* public function getCMSFields() {
|
||||||
* $fields = parent::getCMSFields();
|
* $fields = parent::getCMSFields();
|
||||||
* $galleries = DataObject::get('Gallery');
|
* $field = new DropdownField('GalleryID', 'Gallery', DataList::create('Gallery')->map('ID', 'Title'));
|
||||||
* if ($galleries) {
|
* $field->setHasEmptyDefault(true);
|
||||||
* $galleries = $galleries->toDropdownMap('ID', 'Title', '(Select one)', true);
|
* $field->setEmptyString('(Select one)');
|
||||||
* }
|
* $fields->addFieldToTab('Root.Content', $field, 'Content');
|
||||||
* $fields->addFieldToTab('Root.Content', new DropdownField('GalleryID', 'Gallery', $galleries), 'Content');
|
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* As you see, you need to put "GalleryID", rather than "Gallery" here.
|
* As you see, you need to put "GalleryID", rather than "Gallery" here.
|
||||||
|
Loading…
Reference in New Issue
Block a user