public function insert($data) { $contact = new \AddressBook\Entity\Contact(); $hydrator = new \DoctrineModule\Stdlib\Hydrator\DoctrineObject($this->em); $inputFilter = new \AddressBook\InputFilter\ContactInputFilter($this->em); $this->form->setInputFilter($inputFilter); $this->form->setData($data); if ($this->form->isValid()) { $hydrator->hydrate((array) $data, $contact); $this->em->persist($contact); $this->em->flush(); return true; } return false; }