[英]Check for form errors on View
Is there a convenient way to check if there are any errors on a form on the view without having to modify the controller or looping across all the elements of my form. 是否有一种方便的方法来检查视图上的表单是否存在任何错误,而无需修改控制器或遍历表单的所有元素。
I can do something like: 我可以做类似的事情:
isset($this->formElementErrors($registrationForm->get('firstName')))
This is not quite elegant and again, i will need to call that for every element on my form. 这不是很优雅,再次,我将需要为表单上的每个元素调用它。 So is there any way to know if there is any error on the form compilation?
那么,有什么方法可以知道表单编译是否存在任何错误?
$form->getMessages()
或$form->getInputFilter()->getMessages()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.