# Adv. Rails Recipes - Select List CSS Style

**URL:** <https://www.ruby-forum.com/t/adv-rails-recipes-select-list-css-style/126992>\
**Category:** Rails\
**Created:** [January 23, 2008, 11:40pm UTC](https://www.ruby-forum.com/t/adv-rails-recipes-select-list-css-style/126992 "2008-01-23T23:40:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [January 23, 2008, 11:40pm UTC](https://www.ruby-forum.com/t/adv-rails-recipes-select-list-css-style/126992/1 "2008-01-23T23:40:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [January 24, 2008, 9:04am UTC](https://www.ruby-forum.com/t/adv-rails-recipes-select-list-css-style/126992/2 "2008-01-24T09:04:45Z")

</div>

# haven’t used that recipe. However I assume it involves over riding form methods so as to include the tag, you can do this with

# f.label :is\_active

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [January 24, 2008, 3:19pm UTC](https://www.ruby-forum.com/t/adv-rails-recipes-select-list-css-style/126992/3 "2008-01-24T15:19:09Z")

</div>

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’ %\>

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [January 24, 2008, 4:30pm UTC](https://www.ruby-forum.com/t/adv-rails-recipes-select-list-css-style/126992/4 "2008-01-24T16:30:25Z")

</div>

Spoke too soon - that’s didn’t work.

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [January 24, 2008, 4:29pm UTC](https://www.ruby-forum.com/t/adv-rails-recipes-select-list-css-style/126992/5 "2008-01-24T16:29:12Z")

</div>

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’ %\>
