Support the ongoing development of Laravel.io →
Eloquent Blade Forms

I've found a few examples of using optgroup, but they all seem to be missing what i'm looking for In the db, table with some parent_ids (in same table). id name parent_id 1 Test 0 2 Test2 0 3 WithChild 0 9 Child 3

I am already php hacking to build my array that basically looks like this

[0] => Array
        [id] => 1
        [name] => Test
 )

[1] => Array
    (
        [id] => 2
        [name] => Test2
      
    )

[2] => Array
    (
        [id] => 3
        [name] => WithChild
        [_children] => Array
            (
                [0] => Array
                    (
                        [id] => 9
                        [name] => Child

And i am having problems with creating the following.

                                <select>
                                    <option value="1">Test</option>
                                    <option value="2">Test2</option>
                                    <optgroup label="With Child">
                                          <option value="9">Child</option>
                                       etc

I can(and am at the moment), hack it with normal php. But cannot work out the laravel way to do it

Any suggestions please ?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.