Ryan
Ryan

Reputation: 2460

Specifying html attributes with form_for helper methods

Is it possible to specify html attributes while using the form_for helper methods?

For example:

<% form_for @user do |f| %> 
   <%= f.label :username%>
   <%= f.text_field :username %>
   <%= f.submit "Signn Up" %>
<% end %>

How would I go about specifying the class for the label? Is it possible, or do I have to resort to label()?

Upvotes: 1

Views: 538

Answers (1)

Lucas
Lucas

Reputation: 1210

On mostly helpers, the last arg is a hash of html options for the element.

   <%= f.label :username, "Username", :class => "class" %>

Upvotes: 4

Related Questions