private function buildOptions(&$select, $range) { foreach ($range as $value) { $option = new Option(); $option->setValue($value, true); $option->setLabel($value); $select->addOption($option); } }
public function source($options) { foreach ($options as $key => $label) { if (is_object($label)) { $key = $label->getKey(); $label = $label->getValue(); } $option = new Option(); foreach ($this->pushSave as $name => $value) { $option->push($name, $value); } $option->setValue($key); $option->setLabel($label); $this->parent->addOption($option, $this->position); } }
/** * Creates an option and adds it to the receiver * * @param String $value * @param String $label * @param (boolean) $checked * @param (String) $id */ public function createOption($value, $label, $checked = false, $id = null) { // by incoming request $val = $this->getRequestValue(); if ($val != null && $val == $value) { $checked = true; } else { if ($val != null && $val != $value) { $checked = false; } } $option = new Option(); $option->setValue($value); $option->setLabel($label); $option->setChecked($checked); if (!is_null($id)) { $option->setId($id); } $this->options[] = $option; return $option; }