Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 - how can I customize text-label in label helper?

This is probably a bit low question, but is there any elegant way, how to change the label-text in label helper?

= f.label :name

generate

<input id="car_name" name="car[name]" size="30" type="text">

If I would like to have the text in label, say, Your Car instead of Name, how to do that?

One way is to write the label tag directly as HTML, but this is a bit dirty way...

like image 364
user984621 Avatar asked May 06 '12 19:05

user984621


1 Answers

Just add a second string argument to f.label, like this:

label_tag 'name', 'Your name'
# => <label for="name">Your Name</label>

See here

like image 70
yalestar Avatar answered Nov 28 '22 23:11

yalestar