I am a basic user of Symfony2 and doctrine. I'm thinking what is the best solution to check if a value sent via form exist in database. For now my only solution is:
I suppose it is not the most professional way. Can somebody give me any guidelines? I heard something about own validator but I have never used it. Is it a good idea? Maybe a better way is to use doctrine inside Entity? Maybe in-build asserts can solve the problem? As I know rather not but I could omit something...
Thanks for help in advance.
Maybe in-build asserts can solve the problem?
A big Yes! ;-)
Take a look at
UniqueEntity constraint . It will do the job for you.