2008-09-29 05:18:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EditableDropdown
|
2009-04-17 04:26:40 +02:00
|
|
|
*
|
2008-09-29 05:18:23 +02:00
|
|
|
* Represents a modifiable dropdown box on a form
|
2009-04-17 04:26:40 +02:00
|
|
|
*
|
|
|
|
* @package userforms
|
2008-09-29 05:18:23 +02:00
|
|
|
*/
|
2009-04-17 04:26:40 +02:00
|
|
|
class EditableDropdown extends EditableMultipleOptionField {
|
2008-09-29 05:18:23 +02:00
|
|
|
|
|
|
|
static $singular_name = 'Dropdown';
|
|
|
|
|
2009-04-17 04:26:40 +02:00
|
|
|
static $plural_name = 'Dropdowns';
|
2008-09-29 05:18:23 +02:00
|
|
|
|
|
|
|
|
2009-04-17 04:26:40 +02:00
|
|
|
function createField($asFilter = false) {
|
2008-09-29 05:18:23 +02:00
|
|
|
$optionSet = $this->Options();
|
|
|
|
$options = array();
|
|
|
|
|
2009-04-17 04:26:40 +02:00
|
|
|
if($asFilter) {
|
2008-09-29 05:18:23 +02:00
|
|
|
$options['-1'] = "(Any)";
|
2009-04-17 04:26:40 +02:00
|
|
|
}
|
2008-09-29 05:18:23 +02:00
|
|
|
$defaultOption = '-1';
|
|
|
|
|
|
|
|
foreach( $optionSet as $option ) {
|
|
|
|
$options[$option->Title] = $option->Title;
|
2009-04-17 04:26:40 +02:00
|
|
|
if($option->getField('Default') && !$asFilter) $defaultOption = $option->Title;
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return new DropdownField( $this->Name, $this->Title, $options, $defaultOption );
|
|
|
|
}
|
2009-04-17 04:26:40 +02:00
|
|
|
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
|
|
|
?>
|