Laravel 4 form model binding Form::select

laravel, laravel-4

Solution

I think your 3rd parameter in the select needs to be the selected value:

{{ Form::select('gender', array('0' => 'What gender are you?', '1' => 'Male', '2' => 'Female'), $profile->gender) }}

I know it kinda defeats the purpose of model binding but it will actually work. Other issue of course is that now you've lost your class!

But if we have a quick look at the api:

select( string $name, array $list = array(), string $selected = null, array $options = array() )

We see that you can pass your options array as the 4th argument.

Therefore, the working code is:

{{ Form::select('gender', array('0' => 'What gender are you?', '1' => 'Male', '2' => 'Female'), $profile->gender, array('class' => 'span12')) }}

Problem

OK after reading the documentation: http://four.laravel.com/docs/html#form-model-binding I have a form that looks something like this: ``` {{ Form::model($profile, array('action' => 'ProfilesController@edit', $profile->user_id, 'files' => true)) }} {{ Form::select('gender', array('0' => 'What gender are you?', '1' => 'Male', '2' => 'Female'), array('class' => 'span12')) }} {{ From::close() }} ``` My problem is: model binding does not work with Form::select, works great with text input. What am I doing wrong?? Thanks for your help.

Original source