Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement <optgroup> in laravel blade templeting engine

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

like image 351
Md. Sahadat Hossain Avatar asked Nov 24 '14 05:11

Md. Sahadat Hossain


1 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'.

like image 125
Matt Burrow Avatar answered Oct 08 '22 02:10

Matt Burrow