Skip to content

NoObjectExists can I use a DQL? #192

Closed
chrvadala opened this Issue Mar 15, 2013 · 2 comments

2 participants

@chrvadala

Hi, I think that this a feature that you haven't implemented yet, but however I want ask you

I have this input


$this->inputFilter->add($factory->createInput(array(
                'name'     => 'email',
                'required' => true,
                'filters'  => array(
                    array('name' => 'StripTags'),
                    array('name' => 'StringTrim'),
                ),
                'validators' => array(
                    array(
                        'name' => 'EmailAddress',
                    ),
                    array(
                        'name' => 'StringLength',
                        'options' => array(
                            'min' => 8,
                            'max' => 50,
                        )
                    ),
                    array(
                        'name' => 'DoctrineModule\Validator\NoObjectExists',
                        'options' => array(
                            'object_repository' => $this->getUserRepository(),
                            'fields'            => 'email',
                            'messages' => array(
                                'objectFound' => 'Questo indirizzo email è già esistente'
                            ),
                        )
                    )
                )
            )));

If I use this form to create a new user it works well, but if i want to edit an already existent account there is a problem (because rightly it exists).

Can I specific a research subset like with the new extended element version mode (https://github.com/doctrine/DoctrineModule/blob/master/docs/form-element.md)?

@Ocramius
Doctrine member

Just build your own validator. This is not really suited for DoctrineModule

@Ocramius Ocramius closed this Mar 15, 2013
@chrvadala

Thank you ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.