public function addAction() { $form = new CursoForm($this->getEntityManager()); $form->get('submit')->setAttribute('label', 'Add'); $request = $this->getRequest(); if ($request->isPost()) { $curso = new Curso(); $form->setInputFilter($curso->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $curso->populate($form->getData()); $departamento = $this->getEntityManager()->getRepository('Professor\\Entity\\Departamento')->findOneBy(array('iddepartamento' => $curso->getDepartamentoCurso())); $curso->setDepartamentoCurso($departamento); $this->getEntityManager()->persist($curso); $this->getEntityManager()->flush(); // Redirect to list of albums return $this->redirect()->toRoute('curso'); } } return array('form' => $form); }
/** * {@inheritDoc} */ public function getInputFilter() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getInputFilter', array()); return parent::getInputFilter(); }