2
在我的地盘,我想用不同的验证(例如 - 在我的注册页面 - 我使用客户端验证,但在我的职位页 - 我用标准的审定=>Rails的客户端验证
<% if post.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
但是当我提出我的空单 - 我看到了标准的验证和客户端验证
它本身增加了“不能为空”(我的图片 - 场下有标题和正文)
我认为这使得config/initializers/client_side_validation.rb
:
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
unless html_tag =~ /^<label/
%{<div class="field_with_errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label></div>}.html_safe
else
%{<div class="field_with_errors">#{html_tag}</div>}.html_safe
end
end
我该如何关闭它,仅限于这种形式?
没有,这是我的第一个想法,但是当我点击领域 - 没有什么变化......但是当我提交表单 - 然后创建此