11175
(-- --)
January 23, 2008, 10:40pm
1
I'm using CSS to style form based on the Advanced Rails Recipe #22 for
DRY forms. Everything is working great. The only exception is the
select lists.
To generate all of the fields, I only need to put in this line:
<%= f.text_field :name %>
or
<%= f.check_box :is_active %>
And it generates the label and the field.
This doesn't work the same way for the select lists.
Currently I have this:
<%= f.select :is_active, [ ['True', true],['False', false] ], {}, :label
=> 'Is Active' %>
But it does not generate a label to go with the field. Does anyone have
experience using this recipe and creating select lists?
Thanks.
11175
(-- --)
January 24, 2008, 8:04am
2
haven't used that recipe. However I assume it involves over riding form
methods so as to include the <label> tag, you can do this with
11175
(-- --)
January 24, 2008, 2:19pm
3
For all of the other types of fields, I can simply add the label tag in
the tag so that it looks like this:
<%= f.text_field :is_active, :label => 'Is Active' %>
But this doesn't appear to work for this
<%= f.select :is_active, [ ['True', true],['False', false] ], {}, :label
=> 'Is Active' %>
11175
(-- --)
January 24, 2008, 3:29pm
4
Figured it out... the {} is the options hash and by removing the
brackets, it recognized the label.
<%= f.select :is_active, [ ['True', true],['False', false] ], :label
=> 'Is Active' %>
11175
(-- --)
January 24, 2008, 3:30pm
5
Spoke too soon - that's didn't work.