tag. * @package forms * @subpackage fields-basic */ class DropdownField extends FormField { protected $source; protected $isSelected, $disabled; /** * Creates a new dropdown field. * * $source parameter can be a two dimensional array; creating elements * as needed for the first level of the array, and "; foreach($title as $value2 => $title2) { $selected = $value2 == $this->value ? " selected=\"selected\"" : ""; if($selected && $this->value != 0) { $this->isSelected = true; } $options .= "$title2"; } $options .= ""; } else { // Fall back to the standard dropdown field $selected = $value == $this->value ? " selected=\"selected\"" : ""; if($selected && $this->value != 0) { $this->isSelected = true; } $options .= "$title"; } } } $id = $this->id(); $disabled = $this->disabled ? " disabled=\"disabled\"" : ""; return ""; } 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); $field->setReadonly(true); return $field; } function extraClass(){ $ret = parent::extraClass(); if($this->extraClass) $ret .= " $this->extraClass"; return $ret; } } /** * Dropdown field with an add button to the right. * 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 * @package forms * @subpackage fields-basic */ 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