Hi,

I am trying to use

DoctrineModule\Validator\UniqueObject

as validator within a zf2 form with annotations:

    /**
     * @var string
     *
     * @Annotation\Type("email")
     * @Annotation\Required(true)
     * @Annotation\Filter({"name":"Zend\Filter\StringTrim"})
     * @Annotation\Filter({"name":"Zend\Filter\StripTags"})
* @Annotation\Validator({"name":"Zend\Validator\StringLength", "options":{"min":6, "max":128, "encoding":"UTF-8"}}) * @Annotation\Validator({"name":"DoctrineModule\Validator\UniqueObject"}) * @Annotation\Options({"label":"Email", "column-size":"sm-10", "label_attributes":{"class":"col-sm-2"}})
     * @Annotation\Flags({"priority": 93})
     *
     * @ORM\Column(name="email", type="string", length=128, nullable=false)
     */
    protected $email;


Because I need to inject object_repository and object_manager I tried to register a factory:

            'factories' => array(
                'DoctrineModule\Validator\UniqueObject' => function ($sm){
$uniqueObject = new DoctrineModule\Validator\UniqueObject(array(
                        'fields' => 'email',
'object_repository' => $sm->get('Doctrine\ORM\EntityManager')->getRepository('Crm\Entity\User'), 'object_manager' => $sm->get('Doctrine\ORM\EntityManager'),
                    ));
                    return $uniqueObject;
                }
            )

I tried under different configs:
Module getValidatorConfig
Module getFormElementConfig
    or under
'form_elements'
'validators'
etc

No luck...

I am getting the:
PHP Catchable fatal error: Argument 1 passed to DoctrineModule\\Validator\\UniqueObject::__construct() must be of the type array, none given, called in /home/www/app/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php on line 207 and defined in /home/www/app/vendor/doctrine/doctrine-module/src/DoctrineModule/Validator/UniqueObject.php on line 66


Any clue where to register this ?

Cristian

--
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com


Reply via email to