/** * Builds an HTML Select (dropdown) * * $options (second param) is in $value => $label format: * 'OH' => 'Ohio' * '1' => 'January' * and so on. * * <select name="$name"> * <option>...</option> * ... * </select> * * @param string The name attribute of the select * @param array The options for the select, $value => $label * @param string The default value, matches a key in the Options map * @return Sprocket the Sprocket Select tag, with all options */ public static function SelectInput($name, $options, $default = null) { $tag = new Sprocket('select'); $tag->name = $name; foreach ($options as $value => $label) { $option = $tag->option($label); if ($value == $default) { $option->selected = 'selected'; } $option->value = $value; } return $tag; }