我试图在某些字段上验证失败时显示一般性错误消息,以及其他字段失败时的更具体的消息。但是,我一直无法找出一种方法来检查按键是否存在多个错误。Play Framework 1.2.4:检查是否存在特定错误
我知道我可以用#{ifError 'key'}
检查一个错误,我可以用#{ifErrors}
检查多个错误,但是如何检查多个错误键,如#{if (error 'keyA' || error 'keyB')}
?多个if语句不起作用,因为如果存在某些错误,我希望只显示一次通用消息。
我想要做的是显示在下面的代码片段:
<!-- Only if there's an error on the 'specific' field will this div
be populated. -->
<div class="specificError">#{error 'specific' /}</div>
<!-- If there are other errors, display a generic error message.
This if statement won't compile but shows what I want to do. -->
#{if (error 'fieldA' || error 'fieldB')}
<div class="genericValidateError">&{'error.validation'}</div>
#{/if}
所有建议,欢迎,其中包括建议的替代验证方法。
我在文档中找不到示例,但是您的建议没有办法。谢谢! – 2011-12-28 20:22:06