tag. */ class DropdownField extends FormField { protected $source; protected $isSelected, $disabled; /** * Creates a new dropdown field. * @param $name The field name * @param $title The field title * @param $source An map of the dropdown items * @param $value The current value * @param $form The parent form * @param $emptyString mixed Add an empty selection on to of the {source}-Array * (can also be boolean, which results in an empty string) */ function __construct($name, $title = "", $source = array(), $value = "", $form = null, $emptyString = null) { if(is_string($emptyString)) { $source = is_array($source) ? array(""=>$emptyString) + $source : array(""=>$emptyString); } elseif($emptyString === true) { $source = is_array($source) ? array(""=>"") + $source : array(""=>""); } $this->source = $source; parent::__construct($name, $title, $value, $form); } /** * Returns a name\" id=\"$id\">$options"; } function isSelected(){ return $this->isSelected; } function getSource() { return $this->source; } function setSource($source) { $this->source = $source; } function performReadonlyTransformation() { $field = new LookupField($this->name, $this->title, $this->source); $field->setValue($this->value); $field->setForm($this->form); return $field; } function extraClass(){ $ret = parent::extraClass(); if($this->extraClass) $ret .= " $this->extraClass"; return $ret; } } /** * The class is originally designed to be used by RelatedDataEditor * However, it can potentially be used as a normal dropdown field with add links in a normal form */ class DropdownField_WithAdd extends DropdownField { protected $addText, $useExistingText, $addLink, $useExistingLink; public $editLink; function __construct($name, $title = "", $source = array(), $addLink=null, $useExistingLink=null, $addText="Add", $useExistingText="Use Existing", $value = "", $form = null){ parent::__construct($name, $title, $source, $value, $form); $this->addText = $addText; $this->useExistingText = $useExistingText; $this->addLink = $addLink; $this->useExistingLink = $useExistingLink; } function emptyString($string){ } /** * Returns a