dimanche 30 août 2015

select2.js and select with content of two columns visible - laravel

I have a form and a select field in it. I also use select2.js to style the field

The select is populated by this collection

$dis = array(null => 'Please select district name...') + District::orderBy('id','asc')->lists('name_region', 'id')->all();

The code in my view is

{!! Form::select('electoraldistrict_id', $dis, Input::old('electoraldistrict_id')) !!}

Problem: Now in the select field I only see the name of the district.

How I can make the form to display BOTH id and name - so that in the field I would see sht like this:

1 - first district
2 - second district

instead of

first district
second district



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NGJkrR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire