2

I need to create a optgroupt with laravel collective.

Below is my current code:

<select id="cmb" name="cmb">
   <option></option>
   @foreach($sedeCaptura as $i)
      <optgroup label="SEDE - {{ $i["SedeCaptura"] }}">
         <option value="{!! $i["SedeCaptura"] !!}" >
            {!! $i["IdField"].' - '.$i["DescriptionField"].' - ('.$i["TotalField"].')' !!}
         </option>
      </optgroup>
   @endforeach
</select>

How do I recreate this code with laravel collective?

thisiskelvin
  • 4,136
  • 1
  • 10
  • 17
C47
  • 639
  • 10
  • 19

1 Answers1

3

A simple multidimensional array should do the job as specified in the documentation you can pass a key for the label and an array of key => value pair as follow:

echo Form::select('animal',[
    'Cats' => ['leopard' => 'Leopard'],
    'Dogs' => ['spaniel' => 'Spaniel'],
]);
simonecosci
  • 1,194
  • 7
  • 13