如何使用简单表单输出字段的完整错误消息?相当于rails:<%= RESOURCE.errors.full_messages %>
e.g。显示这个:
"Email has already been taken",
"Password confirmation doesn't match Password",
"Password is too short (minimum is 8 characters)"
代替:f.error_notification
"has already been taken",
"doesn't match Password",
"is too short (minimum is 8 characters)"
simple_form(3.0.2)/ Rails 4.1.1
答案 0 :(得分:7)
如果有人仍然想知道现在有一种简单的方法可以做到这一点,如引用here
只需在config/initializers/simple_form.rb
将b.user :error
更改为b.user :full_error
,现在您的错误消息将等同于RESOURCE.errors.full_messages
注意:如果您使用带简单表单的bootstrap,则更改simple_form_bootstrap.rb