We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I'm using UniqueObject validator but I receive this error:
Expected context to contain id
In my fieldset definition, I have this:
public function getInputFilterSpecification() { return array( 'identifier' => array( 'required' => true, 'validators' => array( array( 'name' => 'DoctrineModule\Validator\UniqueObject', 'options' => array( 'object_manager' => $this->objectManager, 'object_repository' => $this->objectManager->getRepository('Project\Entity\Project'), 'fields' => 'identifier', 'messages' => array( 'objectNotUnique' => 'Sorry, a project with this identifier already exists !', ) ) ), ), ), 'name' => array( 'required' => true ), 'description' => array( 'required' => true ), ); }
My table have id primary key and identifier is a unique field (string).
This only works on primary keys? (if I set 'fields' => 'id', I don't receive the error). What I'm missing?
Thanks in advance. IM
The text was updated successfully, but these errors were encountered:
The problem here is that we actually use the $context parameter passed to isValid (which is wrong, IMO).
$context
isValid
Yes, your compared fields should be the same ones reported in the fields option of the validator.
fields
Dupe of #377
Sorry, something went wrong.
I had the same error in 2023. The solution is to include the "id" field of the entity as the form element in the form class as a hidden field.
$this->add([ 'name' => 'id', 'type' => Element\Hidden::class ]);
Ocramius
No branches or pull requests
Hi,
I'm using UniqueObject validator but I receive this error:
In my fieldset definition, I have this:
My table have id primary key and identifier is a unique field (string).
This only works on primary keys? (if I set 'fields' => 'id', I don't receive the error).
What I'm missing?
Thanks in advance.
IM
The text was updated successfully, but these errors were encountered: