repository = $repository; parent::__construct(); $this->setName('add-client'); $this->setAttribute('action', '/clients/add'); $this->setAttribute('method', 'post'); //Fieldset One $this->add(array( 'name' => 'fsOne', 'type' => 'Zend\Form\Fieldset', 'options' => array( 'legend' => 'Client informations', ), 'elements' => array( // Name array( 'spec' => array( 'name' => 'name', 'type' => 'Zend\Form\Element\Text', 'attributes' => array( ), 'options' => array( 'label' => 'Client name', ), ), ), // Website array( 'spec' => array( 'name' => 'website', 'type' => 'Zend\Form\Element\Text', 'attributes' => array( ), 'options' => array( 'label' => 'Website', 'prependText' => 'http://', ), ), ), // Contact array( 'spec' => array( 'name' => 'contact', 'type' => 'Zend\Form\Element\Text', 'attributes' => array( ), 'options' => array( 'label' => 'Contact client', ), ), ), // Email array( 'spec' => array( 'name' => 'email', 'type' => 'Zend\Form\Element\Email', 'attributes' => array( 'required' => 'required' ), 'options' => array( 'label' => 'Email', ), ), ), // Phone array( 'spec' => array( 'name' => 'phone', 'type' => 'Zend\Form\Element\Text', 'attributes' => array( ), 'options' => array( 'label' => 'Phone number', ), ), ), // Comment array( 'spec' => array( 'name' => 'comment', 'type' => 'Zend\Form\Element\Textarea', 'attributes' => array( ), 'options' => array( 'label' => 'Comment', ), ), ), ), )); //Csrf $this->add(new Element\Csrf('csrf')); //Submit button $this->add(array( 'name' => 'submitBtn', 'type' => 'Zend\Form\Element\Submit', 'attributes' => array( 'value' => 'Add client', ), 'options' => array( 'primary' => true, ), )); //Reset button $this->add(array( 'name' => 'resetBtn', 'attributes' => array( 'type' => 'reset', 'value' => 'Reset', ), )); } public function getInputFilterSpecification() { // die(var_dump($this->serviceManager->getRepository('Fcm\Entity\Client')->checkIfEmailExists("test@test.com"))); // !!! WORKS return array( 'email' => array( 'validators' => array( array( 'name' => 'DoctrineModule\Validator\NoObjectExists', 'options' => array( 'object_manager' => $repository, 'fields' => 'email' ) ) ) ) ); } }