开发者

Specifying html attributes with form_for helper methods

开发者 https://www.devze.com 2022-12-19 09:27 出处:网络
Is it possible to specify html attributes while using the form_for helper methods? For example: <% form_for @user do |f| %>

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

For example:

<% form_for @user do |f| %> 
   <%= f.labe开发者_如何学Cl :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()?


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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号