我试图simple_form
完全停止添加错误标签。
尝试了以下CSS:
label.error { display:none; }
但是simple_form
的 JavaScript 在生成时设置了以下规则:
display: block;
我是否缺少让我完全关闭生成的配置?
这会阻止它们出现,目前有效:
label.error {
display: none !important;
visibility:hidden;
}
我试图simple_form
完全停止添加错误标签。
尝试了以下CSS:
label.error { display:none; }
但是simple_form
的 JavaScript 在生成时设置了以下规则:
display: block;
我是否缺少让我完全关闭生成的配置?
这会阻止它们出现,目前有效:
label.error {
display: none !important;
visibility:hidden;
}
试试这个:
<%= f.input :password, error: false %>
来源@lib/simple_form/components/errors.rb
如果你想禁用所有字段,我相信你必须把它放在所有字段上。
You can also disable labels, hints or error or configure the html of any of them:
<%= simple_form_for @user do |f| %>
<%= f.input :username, :label_html => { :class => 'my_class' } %>
<%= f.input :password, :hint => false, :error_html => { :id => "password_error"} %>
<%= f.input :password_confirmation, :label => false %>
<%= f.button :submit %>
<% end %>
For further reference check the link below:
如果您想禁用站点范围内的输入错误消息,您可以在初始化程序中轻松设置config/initializers/simple_form.rb
:
SimpleForm.setup do |config|
config.wrappers :default, class: :input,
# Comment this line!
#b.use :error, wrap_with: { tag: :span, class: :error }
end
end
您将不再在每个输入旁边看到验证消息。
在 Rails 5 中,执行以下操作以从上方删除输入字段下方的提示和标签
<%= f.input :password, required: true, label: false, hint: false %>