错误消息总是包含属性名称 [英] Error messages always include attribute name
本文介绍了错误消息总是包含属性名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试提交空白表单时出现以下验证错误消息:
I have the following validation error messages coming up when I try to submit a blank form:
Start time time Looks like you forgot the appointment start time.
Start time time Sorry, we can't understand "" as a time.
Start time ymd Please choose a date for the appointment.
Start time ymd Sorry, we can't understand "" as a date.
Stylist services Please choose at least one service.
这些消息针对以下属性:
These messages are for the following attributes:
start_time_time
start_time_time
start_time_ymd
start_time_ymd
stylist_services
我包含了属性名称,以便您可以清楚地看到错误消息的哪一部分是属性名称.
I included the attribute names so you could plainly see which part of the error message is the attribute name.
如何从错误消息中删除属性名称?
How do I remove the attribute names from the error messages?
推荐答案
您可以使用 i18n 路由来更改属性的显示名称.
You could use the i18n route to change the display name of the attribute.
en:
activerecord:
attributes:
somemodel:
start_time_time: My Start Time Text #renamed text
stylist_services: "" #hidden txet
这篇关于错误消息总是包含属性名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文