Symfony2: my form returns false from isValid() but empty array for getErrors() from unique constraint condition

前端 未结 6 850
天命终不由人
天命终不由人 2021-02-13 04:02

I have a Customer entity that only has a unique Email field to it. I am trying to edit a customer\'s email and the validation works fine. However I have this in my controller:

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-13 04:31

    For debug purposes you can use $form->getErrorsAsString() instead of $form->getErrors() if you use Symfony 2.*

    Quoted from this answer:

    $form->getErrorsAsString() should only be used to debug the form...it will contain the errors of each child elements which is not the case of $form->getErrors().


    UPDATE 1:

    "With more recent Symfony versions, you must use $form->getErrors(true, false); instead. First param corresponds to deep and second to flatten" (see the comment by @Roubi)

提交回复
热议问题