diff --git a/src/FormBuilder.php b/src/FormBuilder.php
index a0cb439..dd2753a 100644
--- a/src/FormBuilder.php
+++ b/src/FormBuilder.php
@@ -699,20 +699,23 @@ class FormBuilder
* @param string $selected
* @param array $attributes
* @param array $optionsAttributes
+ * @param integer $level
*
* @return \Illuminate\Support\HtmlString
*/
- protected function optionGroup($list, $label, $selected, array $attributes = [], array $optionsAttributes = [])
+ protected function optionGroup($list, $label, $selected, array $attributes = [], array $optionsAttributes = [], $level = 0)
{
$html = [];
-
+ $space = str_repeat(" ", $level);
foreach ($list as $value => $display) {
$optionAttributes = $optionsAttributes[$value] ?? [];
-
- $html[] = $this->option($display, $value, $selected, $optionAttributes);
+ if (is_array($display)) {
+ $html[] = $this->optionGroup($display, $value, $selected, $attributes, $optionAttributes, $level+5);
+ } else {
+ $html[] = $this->option($space.$display, $value, $selected, $attributes, $optionAttributes);
+ }
}
-
- return $this->toHtmlString('');
+ return $this->toHtmlString('');
}
/**