将属性添加到R​​ails助手文本字段? [英] Add attribute to rails helper text field?

查看:92
本文介绍了将属性添加到R​​ails助手文本字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个来自devise的rails helper文本字段,该文本字段使用html并自动验证了type="email"字段.我想向其中添加属性novalidate='novalidate',但是我不知道如何..这是代码..有什么建议吗?

I have a rails helper text field from devise that uses html and atomatically validates the type="email" field. I want to add the attribute novalidate='novalidate' to it, but i do not know how.. Heres the code.. any suggestions?

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)
) do |f| %>
  <p><%= f.label :login %><br />
  <%= f.email_field :login %></p>

推荐答案

只需:

<%= f.email_field :login, :novalidate => 'novalidate' %>

更新-如果要向FORM标签添加属性,语法略有不同:

UPDATE -- If you want to add an attribute to the FORM tag, the syntax is slightly different:

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:novalidate => 'novalidate'}) do |f| %>

这篇关于将属性添加到R​​ails助手文本字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆