Esempio n. 1
0
 public function addAction()
 {
     $form = new StateForm();
     $form->get('submit')->setValue('Add');
     //Populate Country DropDown
     $idcountryOptions = array();
     foreach ($this->getCountrySelectData() as $country) {
         $idcountryOptions[$country->getIdcountry()] = $country->getName();
     }
     $form->get('idcountry')->setAttribute('options', $idcountryOptions);
     // CSS
     $form->get('name')->setAttribute('class', 'form-control');
     $form->get('idcountry')->setAttribute('class', 'form-control');
     $form->get('name')->setAttribute('placeholder', 'Ej.: Paris');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $state = new State();
         $form->setInputFilter($state->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             //Debug::ddump($form->getData()['idcountry']);
             $state->exchangeArray($form->getData());
             //Debug::dump($form->getData('idcountry'), '>form >idcountry');
             $state->setIdcountry($this->getEntityManager()->find('Application\\Entity\\Country', $request->getPost('idcountry')));
             /**Dump State*/
             ///Debug::dump($request->getPost(), '>form >getPost');
             //Debug::dump($state->getIdstate(), '>idstate');
             //Debug::dump($state->getName(), '>name');
             //Debug::dump($state->getIdcountry()->getIdcountry(), '>idcountry');
             //Debug::dump($state->getIdcountry()->getName(), '>idcountry > name');
             //Debug::ddump($state->getDisabled(), '>disabled');
             $this->getEntityManager()->persist($state);
             $this->getEntityManager()->flush();
             // Redirect to Country List
             return $this->redirect()->toRoute('state');
         }
     }
     return array('form' => $form);
 }
 /**
  * {@inheritDoc}
  */
 public function getIdcountry()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIdcountry', array());
     return parent::getIdcountry();
 }