Using Select2 Plugin

  • Created: 12-05-2019
  • Posted By: Safina

Below is the example of how to use Select2 plugin for creating tagged selectable elements:

<div class=form-group>
<label for=tutor_id>Tutor:</label>
<select multiple name=tutor_id[] id=tutor_id class=form-control>
@foreach($tutors as $tutor)
<option value={{$tutor->id}}>{{$tutor->name}}</option>
@endforeach
</select>
</div>

<script>
$(#tutor_id).select2({
placeholder: Select Tutors...,
allowClear: true
})
</script>

Tags:

Post Comments