Support the ongoing development of →
Input Forms
Last updated 3 months ago.
$locations = Locations::orderBy('locNameEN', 'asc')->get();
return View::make('foobar', compact('locations');

// blade

{{ Form::select('loc_name_e_n', null, $locations->lists('locNameEN', 'id')) }}
Last updated 3 months ago.

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 ?

Last updated 3 months ago.
{{ 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.

Last updated 3 months ago.

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!


Your banner here too?

goranata goranata goranata Joined 12 Mar 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 - All rights reserved.