noblemfd
1 week ago

option value not visible in select2 dropdown

Posted 1 week ago by noblemfd

In my Laravel-5.8 I am using Select2 dropdown list

              <select class="form-control select2bs4" data-placeholder="Choose Nationality" tabindex="1" name="nationality_id" style="width: 100%;">
                <option value="">Select Nationality</option>
                     @if($nationalities->count() > 0 )
                     @foreach($nationalities as $nationality)
                       <option value="{{$nationality->id}}">{{$nationality->nationality}}</option>
                     @endforeach
                   @endif
              </select>



    <script>
        $(function () {
          //Initialize Select2 Elements
          $('.select2').select2()

          //Initialize Select2 Elements
          $('.select2bs4').select2({
            theme: 'bootstrap4'
          })
        });
    </script>

It loads the nationalities, but I didn't see this:

<option value="">Select Nationality</option>

in the select2 dropdown?

How do I resolve this?

Thanks

Please sign in or create an account to participate in this conversation.