php - ZendFramework2 posting form -


here method should send forms data database, can't figure out why doesn't work.there no errors showing data not inserted in table. glad if can me out!

//method add data database public function addaction() {         //add user info     $form = new userform();     $form->get('submit')->setvalue('add new info');      $request = $this->getrequest();     if($request->ispost()){         $user = new user();         $form->setdata($request->getpost());          if($form->isvalid()){             $user->exchangearray($form->getdata());//method gets validated data             $this->getusertable()->saveuser($user);              return $this->redirect()->toroute('application',array(                 'controller'=>'user',                 'action'=>'index'             ));         }     }      //pass view      $values = array('form'=>$form);      $view = new viewmodel($values);     return $view; } 

views add.phtml

$form = $this->form;  $form->setattribute('action', $this->url(                 'application', array(             'controller' => 'user',             'action' => 'add',                 ) )); echo $this->form()->opentag($form); echo $this->formhidden($form->get('id')); echo $this->formrow($form->get('name')); echo $this->formrow($form->get('email'));  echo $this->formsubmit($form->get('submit')); echo $this->form()->closetag(); ?> 

 $user = new user(); //user class contains user information can store in db  $user->name = "anime lover"; $user->email = "anime mail"; $this->getusertable()->saveuser($user);  $view = new viewmodel($values); return $view; <- because of return 

-------------- never pass here----------------------

 //add user info etc....  $form = new userform(); 

maybe test ? ?


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -