Simplify handling of tables, entities, forms and validations in ZF2 by using annotations

If you developed any application using ZF2 you may become frustrated of the tedious work of creating boilerplate code for handling common tasks like a simple form which will be validated then saved in a database. The Zend manual recommends creating a table class, an entity class a form class, a validator class, along with […]

Unique record validation in ZF2 forms

Controller code: $employeeInfoValidator = new EmployeeInfoValidator(); $dbAdapter = $this->getServiceLocator()->get(‘Zend\Db\Adapter\Adapter’); $employeeInfoValidator->data = array( ‘UserId’ => $userId, ‘CoveredPersonDependentId’ => $dependentId ); $employeeInfoValidator->setDbAdapter($dbAdapter); $form->setInputFilter($employeeInfoValidator->getInputFilter()); Validator class: