Using Symfony2.3.4, Doctrine2 and PHP5.6.3.
This is my validation.yml
file:
Project\NameBundle\Entity\EntityName:
constraints:
- Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
fields: f1
message: "There is already an entity with the same f1"
fields: f2
message: "There is already an entity with the same f2"
This is just a visual aid to help you understand what I need. This does not work how I want to. This:
When submitting the form:
- Current behavior:
if(f2 is not unique)
error;
else
submits;
Expected behavior:
if(f1 === X.f1 AND f2 === X.f2) //X is any of the entities already in the DB
error;
else
submits;
Just in case, I have already accomplished this in my EntityName.php
class with @UniqueEntity(fields={"f1", "f2"}, message="error")
annotation, but I really need it in .yml
.
Side quest:
Right now, with the annotation approach it is showing the error sign next to only f1
, is there a way to show it next to all involved fields?