如果不接受therm和条件,我想更改错误消息。使用下面的代码,如果给出标准错误消息。我添加了翻译域和无效的消息名称,但这没有任何效果。这有什么问题?
->add('terms', 'checkbox', array(
'mapped' => false,
'constraints' => array(new Assert\IsTrue()),
'translation_domain' => 'validators',
'invalid_message' => 'accept_conditions',
))
答案 0 :(得分:2)
替换:
'constraints' => array(new Assert\IsTrue()),
由:
'required' => true,
约束条件有自己的翻译信息,这就是为什么你的翻译没有任何效果。如果您确实需要/需要继续使用Assert\IsTrue
,请在约束中指定自定义消息:
'constraints' => array(
new Assert\IsTrue(
array('message' => 'accept_conditions')
)
),