Search code examples
phplaravel-4template-enginelaravel-blade

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


Solution

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