[英]Symfony2, difference between isValid() and $this->get('validator')
I'm new in Symfony2 and I wish to know what's the difference of validate a form between: 我是Symfony2的新手,我想知道验证表单之间的区别是什么:
$form->isValid()
and 和
$this->get('validator')->validate($form->getData())
using validation rules in validations.yml 在validations.yml中使用验证规则
Thank you! 谢谢!
The validator, in your case, checks object to which the form was bound. 在您的情况下,验证器检查与表单绑定的对象。 The Form::isValid()
method, besides, checks a form status (whether the form was submitted, whether it was disabled). 此外, Form::isValid()
方法还检查表单状态(是否已提交表单,是否已禁用)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.