public function addAction() { $form = new WinesubtypeForm(); $form->get('submit')->setValue('Add'); //Populate State DropDown $idwinetypeOptions = array(); foreach ($this->getWinetypeSelectData() as $winetype) { $idwinetypeOptions[$winetype->getIdwinetype()] = $winetype->getName(); } $form->get('idwinetype')->setAttribute('options', $idwinetypeOptions); // CSS $form->get('name')->setAttribute('class', 'form-control'); $form->get('name')->setAttribute('placeholder', 'Ej.: Malbec'); $form->get('idwinetype')->setAttribute('class', 'form-control'); $request = $this->getRequest(); if ($request->isPost()) { $winesubtype = new Winesubtype(); $form->setInputFilter($winesubtype->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $winesubtype->exchangeArray($form->getData()); $winesubtype->setIdwinetype($this->getEntityManager()->find('Application\\Entity\\Winetype', $request->getPost('idwinetype'))); $this->getEntityManager()->persist($winesubtype); $this->getEntityManager()->flush(); // Redirect to Country List return $this->redirect()->toRoute('winesubtype'); } } return array('form' => $form); }
/** * {@inheritDoc} */ public function exchangeArray($data = array()) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'exchangeArray', array($data)); return parent::exchangeArray($data); }