/** * Returns the SELECT in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $tabs = $this->_getTabs(); $strHtml = ''; if ($this->getComment() != '') { $strHtml .= $tabs . '<!-- ' . $this->getComment() . " //-->\n"; } if (!$this->getMultiple()) { $attrString = $this->_getAttrString($this->_attributes); } else { $myName = $this->getName(); $this->setName($myName . '[]'); $attrString = $this->_getAttrString($this->_attributes); $this->setName($myName); } $strHtml .= $tabs . '<select' . $attrString . ">\n"; //alternate code to optimize form generation if (!$this->getMultiple() && function_exists('AMP_buildSelectOptions')) { $option_values = array(); foreach ($this->_options as $option) { $option_values[$option['attr']['value']] = $option['text']; } $selected_value = is_array($this->_values) && !empty($this->_values) ? $this->_values[0] : null; $strHtml .= AMP_buildSelectOptions($option_values, $selected_value); } else { //standard QF code foreach ($this->_options as $option) { if (is_array($this->_values) && in_array((string) $option['attr']['value'], $this->_values)) { $this->_updateAttrArray($option['attr'], array('selected' => 'selected')); } $strHtml .= $tabs . "\t<option" . $this->_getAttrString($option['attr']) . '>' . $option['text'] . "</option>\n"; } } return $strHtml . $tabs . '</select>'; } }
function indentedOptions_withNull($selected_value = null) { return AMP_buildSelectOptions(array('' => 'Select Section') + $this->indentedValues(), $selected_value); }
function AMP_buildSelect($name, $values, $selected = null, $attr = false) { return '<select name="' . $name . "\"{$attr}>\n" . AMP_buildSelectOptions($values, $selected) . "\n</select>"; }