diff --git a/laravel/form.php b/laravel/form.php index a768f503..619043ef 100644 --- a/laravel/form.php +++ b/laravel/form.php @@ -397,12 +397,39 @@ public static function select($name, $options = array(), $selected = null, $attr foreach ($options as $value => $display) { - $html[] = static::option($value, $display, $selected); + if (is_array($display)) + { + $html[] = static::optgroup($display, $value, $selected); + } + else + { + $html[] = static::option($value, $display, $selected); + } } return ''.implode('', $html).''; } + /** + * Create a HTML select element optgroup. + * + * @param array $options + * @param string $label + * @param string $selected + * @return string + */ + protected static function optgroup($options, $label, $selected) + { + $html = array(); + + foreach ($options as $value => $display) + { + $html[] = static::option($value, $display, $selected); + } + + return ''.implode('', $html).''; + } + /** * Create a HTML select element option. *