Md. Sahadat Hossain
Md. Sahadat Hossain

Reputation: 3236

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

Upvotes: 9

Views: 9731

Answers (1)

Matt Burrow
Matt Burrow

Reputation: 11057

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

Upvotes: 24

Related Questions