Rails simple_form:如何禁用错误标签?
我试图完全阻止 simple_form
添加错误标签。
尝试了以下 CSS:
label.error { display:none; }
但是 simple_form
的 JavaScript 在生成时设置了以下规则:
display: block;
我是否缺少一个可以让我完全关闭生成的配置?
这会阻止它们出现,目前有效:
label.error {
display: none !important;
visibility:hidden;
}
I'm trying to stop simple_form
from adding error labels entirely.
tried the followign CSS:
label.error { display:none; }
but simple_form
's JavaScript is setting the following rule when it's generated:
display: block;
Am I missing a config that lets me turn off generation entirely?
This stops them from appearing, which works for now:
label.error {
display: none !important;
visibility:hidden;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试一下:
来源@ lib/simple_form/components/errors.rb
如果您想禁用所有字段,我相信您必须将其放在所有字段上。
Give this a try:
Source @ lib/simple_form/components/errors.rb
If you want to disable for ALL fields, I believe you'd have to put this on all fields.
您还可以禁用标签、提示或错误,或配置其中任何一个的 html:
有关进一步参考,请检查以下链接:
https ://github.com/plataformatec/simple_form
You can also disable labels, hints or error or configure the html of any of them:
For further reference check the link below:
https://github.com/plataformatec/simple_form
如果您想在站点范围内的输入上禁用错误消息,您可以在初始化程序
config/initializers/simple_form.rb
中轻松设置:您将不再在每个输入旁边看到验证消息。
If you want to disable error messages on inputs site-wide, you can set this easily in the initialiser
config/initializers/simple_form.rb
:You will no longer see the validation messages beside every input.
在 Rails 5 中,执行以下操作以删除输入字段下方的提示和上方的标签
In Rails 5 do the following to remove the hint underneath the input field and label from above