Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Collection not selecting value #325

cyrilpic opened this Issue · 6 comments

2 participants


If I provide a lambda function to the label_method options, the select input doesn't select any options.

f.input :status, :collection => Project.possible_status, :label_method => lambda { |v| I18n.t v.to_s }

Even if the status attribute of the model is set to a particular value, the html code produced doesn't set the selected option on any options under the select tag.


Which SimpleForm version are you using? We've improved some stuff related to label/value methods and disabled with selects when they're given as procs, perhaps that might be the issue. Thanks.


I'm using SimpleForm 1.5.0. I saw the changes you made to correct issue #307, but it seemed to cause me some troubles.

I can make it work again, by adding :

:selected => lambda { |v| v == f.object.status }

I must probably add that my field is actually a Symbol.


I think I can see what's happening, we might be overriding the :selected option, which makes Rails ignore the current attribute value.. I'll try a fix in the following days.

Thanks for reporting.


Hey mate, I believe the issue was exactly what I had in mind. Could you please try to bundle from github, branch v1.5, and test it? If everything goes fine we will release a new version. Thanks.


Works perfectly now ! Thanks for the quick fix

@klobuczek klobuczek referenced this issue from a commit in klobuczek/simple_form
@carlosantoniodasilva carlosantoniodasilva Do not override attribute value selection in collection select. Closes


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.