I study the doctrine, and I have a form. ZF2 and the doctrine with the email field. This field must be unique, so for this I need a validator. I also use fields (this is important here). The problem is that I use:
DoctrineModule\Validator\UniqueObject
unable to create new object. This validator needs a primary key for comparison. Validator dump error with message:
Expected context to contain itemId
itemId is my primary key.
So, obviously, I need to use UniqueObject to update and:
DoctrineModule\Validator\NoObjectExists
for a new facility. And the question is:
What is the best way to store different input filter specifications for an existing and a new facility?
Or, if possible, better: using a unique validator with new and existing entries with fields of the zend form.
If I put it in a form, I need to change it inside the controller if the object is new or not. Not a good idea.
I think the best way is to keep the input filter specification. inside the entity repository, but how can I check there if the object is new or not?
---- edit
I saw the documentation, I know how to use a unique object, but I have an error, as was said earlier: "The expected context that contains the ItemId". I think the problem is with the fields (they are used). I do not understand how to do this (text from documents):
If you do not specify the use_context option or set the value to false, you must pass an array containing the values ββof the fields and identifier to the action (). When using Zend \ Form, this behavior is necessary if you are using fields .
Ok im using fields so now what can i do? How can I pass the correct isValid values ββwhen im uses zend forms?