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

2010/2/14 Ralph S. [email protected]

Lasse B. wrote:

f.label :something, “something”

:slight_smile: Lasse

2010/2/14 Ralph S. [email protected]

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

2010/2/14 Ralph S. [email protected]

Super – glad you found out :slight_smile:

Lasse

2010/2/14 Ralph S. [email protected]

Ralph S. wrote:

Lasse B. wrote:

f.label :something, “something”

:slight_smile: Lasse

2010/2/14 Ralph S. [email protected]

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


Whatever
Put anything here


associates the label with the input. Thus
(from ActionView::Helpers::FormTagHelper) documentation
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M001606

label(:post, :title)

=> Title

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

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

On Feb 14, 8:31 am, Ralph S. [email protected] wrote:

Lasse B. wrote:

f.label :something, “something”

:slight_smile: Lasse

2010/2/14 Ralph S. [email protected]

Well … that certainly was simple … but then what is the purpose of
the first parameter? What are the downsides to
f.label ‘’, “something”

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

en:
hello: “Hello world”
helpers:
label:
foo:
something: “zomething”

This will make the label for foo’s “something” appear as
“zomething” (lower case).

By using the localization file, you can get consistent displaying. In
addition, you may be able to localize some pages or partials without
having to do _partial.<2letter_code>.html.erb


Kurt W.
Looking for a new rails job: http://www.circlew.org/kurt/pages/resume

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs