我的项目中有一些简单的实体用户代码
/**
* @Assert\NotBlank()
* @Assert\Date()
*/
protected $dateOfBirth;
正如在Official Documentation for Date()上所写,我可以发送日期参数,例如“YYYY-MM-DD”,但在控制器中提交后总是会出现错误
$form = $this->createForm('Application\Sonata\UserBundle\Form\UserType', new User(), array(
'csrf_protection' => false,
));
$form->submit($request->request->all());
响应:
"dateOfBirth": {
"errors": [
"This value is not valid."
],
"children": {
"year": {},
"month": {},
"day": {}
}
}