Change rails text_field form builder type

后端 未结 2 497
你的背包
你的背包 2021-02-10 13:54

I\'ve been looking at the new options available in HTML5 forms, such as declaring input types as \"email\", \"url\", and \"number\", as described here.

How can I use the

相关标签:
2条回答
  • 2021-02-10 13:58

    There is now an email_field tag.

    0 讨论(0)
  • 2021-02-10 14:19

    Looks like there is currently an open ticket and patch for adding the HTML5 form input types. If you can't wait until the patch is accepted, you could apply the patch locally by freezing the actionpack gems and applying the patch or making an initializer that add the extra methods.

    Of course the other option is adding the fields manually without a form helper:

    <% form_for @user do |f| %>
      <%= tag(:input, {:type => :email, :value => f.object.email} %>
    <% end %>
    
    0 讨论(0)
提交回复
热议问题