forcing lower case in form helper label

f.label 'something'

produces   Something instead of   something

How can I force f.label to have a lower case initial letter?

f.label :something, “something”

:slight_smile: Lasse

Lasse Bunk wrote:

f.label :something, "something"

:slight_smile: Lasse

Well ... that certainly was simple .... but then what is the purpose of the first parameter? What are the downsides to   f.label '', "something" ?

Yeah it’s pretty simple :slight_smile:

The purpose of the first parameter is to provide an ID for the label and optionally a default text for the label. This is used if you don’t provide a second parameter.

Check out http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M001604 and http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M001606

:slight_smile: Lasse

Ralph Shnelvar wrote:

Lasse Bunk wrote:

f.label :something, "something"

:slight_smile: Lasse

Well ... that certainly was simple .... but then what is the purpose of the first parameter? What are the downsides to   f.label '', "something" ?

OK ... I sniffed around on the 'net to try to answer my own question.

Apparently the first field becomes the target of the   for= HTML parameter. The "for=" field, in turn, becomes associated with another html tag's (e.g. an input tag.)

So

- - - - - <label for="xyzzy">Whatever</label> Put anything here <input type="checkbox" id="xyzzy" value="check me" /> - - - -

associates the label with the input. Thus (from ActionView::Helpers::FormTagHelper) documentation

label(:post, :title)   # => <label for="post_title">Title</label>

now makes sense to me. One now has a css tag to play with.

Thank you, Lasse Bunk. Sometimes the most trivial of answers helps the most.

Super – glad you found out :slight_smile:

Lasse

That's one option. Another, maybe better in the long run, is to use the localization files. Check out the FormHelper docs. en.yml