0

Hello Guys I'm Working On Laravel And I Want To Set Default Value for select2 Class for search input

 <select name="category[{{$index}}][category_id]"  class="select2 form-control"> // This Is My Select2 class and it contains search input

    <optgroup  label="Select Category">

    @if($Categories && $Categories -> count() > 0)

        @foreach($Categories as $Category)

            <option value="{{$Category-> id }}">

                {{$Category-> translation_lang}}

                {{$Category-> name}}
    
            </option>
    
        @endforeach
    @endif
    </optgroup>


        </select>

I Have select2 class in my select. This Class to add search input to my select. i want to set default value to this search input how can i make it please?????

Laravel
  • 133
  • 11

1 Answers1

0

Use the form helper.

{!!Form::select('category', isset($category) ? $category->id : null, ['id' => 'category', 'class' => 'form-control'])!!}
Darragh Blake
  • 238
  • 1
  • 6