Add support for additional attributes on <option> entries

pull/136/head
Thomas Bruederli 11 years ago
parent 64c924ea06
commit b608577342

@ -604,16 +604,17 @@ class html_select extends html
* *
* @param mixed $names Option name or array with option names * @param mixed $names Option name or array with option names
* @param mixed $values Option value or array with option values * @param mixed $values Option value or array with option values
* @param array $attrib Additional attributes for the option entry
*/ */
public function add($names, $values = null) public function add($names, $values = null, $attrib = array())
{ {
if (is_array($names)) { if (is_array($names)) {
foreach ($names as $i => $text) { foreach ($names as $i => $text) {
$this->options[] = array('text' => $text, 'value' => $values[$i]); $this->options[] = array('text' => $text, 'value' => $values[$i]) + $attrib;
} }
} }
else { else {
$this->options[] = array('text' => $names, 'value' => $values); $this->options[] = array('text' => $names, 'value' => $values) + $attrib;
} }
} }
@ -644,7 +645,7 @@ class html_select extends html
$option_content = self::quote($option_content); $option_content = self::quote($option_content);
} }
$this->content .= self::tag('option', $attr, $option_content); $this->content .= self::tag('option', $attr + $option, $option_content, array('class','style','title','disabled'));
} }
return parent::show(); return parent::show();

Loading…
Cancel
Save