Home » Php » php – How to implement <optgroup> in laravel blade templeting engine

php – How to implement <optgroup> in laravel blade templeting engine

Posted by: admin July 12, 2020 Leave a comment

Questions:

Let I have HTML select box like

<select>
    <optgroup label="Fruits">
     <option>Orange</option>
     <option>Apple</option>
    </optgroup>
    <optgroup label="Food">
     <option>Chicket</option>
     <option>Beef</option>
    </optgroup> 
</select>

Now How can I implement this select box in laravel blade template engine

How to&Answers:

Try this;

{{ Form::select('list', array(
    'Fruits' => array('Orange', 'Apple'),
    'Food' => array('Chicken', 'Beef'),
))}}

The output should be what your looking for.

To assign the values of the select options add keys to the array like '<your_value>' => 'Orange'.