I'm trying to build a select input for a form with multiple layers of group options but I keep getting a "htmlentities() expects parameter 1 to be string, array given" error message.
I have tried different ways to make this work and have looked up documentation, finding plenty of stuff for one option group but nothing for multiple option groups. If anyone could point out where I'm going wrong or just tell me if this is just not allowed in Laravel it would be greatly appreciated! Thanks!
View:
{{ Form::select('example',
array(
'' => "example",
'First group' => array(
"Part A" => array(
'1' => "a",
'2' => "b",
),
"Part B" => array(
'1' => "a",
'2' => "b",
),
),
'Second Group' => array(
"Part A" => array(
'1' => "a",
'2' => "b",
),
"Part B" => array(
'1' => "a",
'2' => "b",
),
),
)) }}
That's because you can not make a select element in html with "multiple layers of group options"!
You can have multiple <optgroup>
tags inside a <select>
tag, and inside an <optgroup>
you can have <option>
s. And Laravel is just trying to make HTML.
http://www.w3.org/TR/html401/interact/forms.html#h-17.6
See these answers for some hacky workarounds: