$locations = Locations::orderBy('locNameEN', 'asc')->get();
return View::make('foobar', compact('locations');
// blade
{{ Form::select('loc_name_e_n', null, $locations->lists('locNameEN', 'id')) }}
Thank You, raymondidema.
However I just realized that the problem exist when I'm adding the Choose a location, like this:
{{ Form::select('locID', array_merge(array('default' => 'Please Select'), $locations->lists('locNameEN', 'locID')), null, array('class' => 'form-control', 'id' => 'locID')) }}
// This is the okay one, but without Choose location, default value ?
{{-- Form::select('locID', $locations->lists('locNameEN', 'locID'), null, array('class' => 'form-control', 'id' => 'locID')) --}}
When I do this it's breaks up the order of the ID's Any solution ?
{{ Form::select('locID', array('default' => 'Please Select') + $locations->lists('locNameEN', 'locID'), 'default', array('class' => 'form-control', 'id' => 'locID', Input::old('locID'))) }}
This is what I was looking for ... 10x your response, it was a great help and lead to the solution.
I had kind of the same problem (L5.2) However I created the object before hand.
This resulted in distorted ID values in the option select menu: User::whereNull('deleted_at')->get()->lists('name', 'id')->prepend('select value');
Simply adding the value too, fixed the problem:
User::whereNull('deleted_at')->get()->lists('name', 'id')->prepend('select value', 0);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community