mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
9f112e3b23
Fix unit test failures
41 lines
817 B
PHP
Executable File
41 lines
817 B
PHP
Executable File
<?php
|
|
/**
|
|
* EditableDropdown
|
|
*
|
|
* Represents a modifiable dropdown (select) box on a form
|
|
*
|
|
* @package userforms
|
|
*/
|
|
|
|
class EditableDropdown extends EditableMultipleOptionField {
|
|
|
|
private static $singular_name = 'Dropdown Field';
|
|
|
|
private static $plural_name = 'Dropdowns';
|
|
|
|
/**
|
|
* @return FieldList
|
|
*/
|
|
public function getCMSFields() {
|
|
$fields = parent::getCMSFields();
|
|
|
|
$fields->removeByName('Default');
|
|
|
|
return $fields;
|
|
}
|
|
|
|
/**
|
|
* @return DropdownField
|
|
*/
|
|
public function getFormField() {
|
|
$field = DropdownField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap());
|
|
|
|
// Set default
|
|
$defaultOption = $this->getDefaultOptions()->first();
|
|
if($defaultOption) {
|
|
$field->setValue($defaultOption->EscapedTitle);
|
|
}
|
|
$this->doUpdateFormField($field);
|
|
return $field;
|
|
}
|
|
} |