Support the ongoing development of Laravel.io →
posted 10 years ago
Input Forms
Last updated 1 year ago.
0
$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 1 year ago.
0

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 1 year ago.
0
{{ 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 1 year ago.
0

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);

0

Sign in to participate in this thread!

Eventy

Your banner here too?

goranata goranata Joined 12 Mar 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.