markhorrocks
markhorrocks

Reputation: 1548

Rails simple_form label for select

I'm trying to set a label for the following line but I keep getting an error if I add label_method anywhere. label: is just ignored. How can I add a label for f.select?

<%= f.select :state_identifier, Location::STATE, { prompt: 'State', id: 'state' } %>

I tried the following but it doesn't format properly in form-horizontal, leaving no gap between the label and data.

<%= f.label :state_identifier, label: 'State' %>

Upvotes: 0

Views: 3402

Answers (1)

Sushil
Sushil

Reputation: 501

This is because f.select is not a simple_form method and does not support :label

Something like this should work for you w/ simple form.

<%= f.input :state_identifier, :label => "State", :collection => ["a","b"], :input_html => {:id=>"state" } %>

Hope this helps.

Upvotes: 1

Related Questions