public function addAction() { $form = new SalaForm($this->getEntityManager()); $form->get('submit')->setAttribute('label', 'Add'); $request = $this->getRequest(); if ($request->isPost()) { $sala = new Sala(); $form->setInputFilter($sala->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $sala->populate($form->getData()); $local = $this->getEntityManager()->getRepository('Sala\\Entity\\Local')->findOneBy(array('idlocal' => $sala->getLocallocal())); $sala->setLocallocal($local); $this->getEntityManager()->persist($sala); $this->getEntityManager()->flush(); // Redirect to list of albums return $this->redirect()->toRoute('sala'); } } return array('form' => $form); }
/** * {@inheritDoc} */ public function getInputFilter() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getInputFilter', array()); return parent::getInputFilter(); }