How do I include the 'autofocus
' attri开发者_C百科bute on an HTML5
form using the text_field
form helper in Rails
?
e.g. <%= f.text_field :email %>
Where does autofocus go?
Thanks
f.text_field :email, autofocus: true
This will work:
text_field_tag :reseller, '', autofocus: true
Note the empty value
argument.
<%= f.text_field :email, nil, :autofocus => true %>
will work.
similarly, if you want to use other HTML5 attributes and CSS classes, you can write :
<%= f.text_field :email, nil, :autofocus => true, :placeholder => "Your email Here", :class => "active", :style => "color: #333;" %>
精彩评论