×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
1
Language: PHP
Posted by: Massimo Zappino
Added: Jan 26, 2011 11:01 AM
Modified: May 16, 2012 8:10 AM
Views: 364
  1. if ($this->getRequest()->isPost()) {
  2.     $postData = $this->getRequest()->getPost();
  3.     $db = Zend_Registry::get('db');
  4.     if ($form->isValid($postData)) {
  5.         try {
  6.             $db->beginTransaction();
  7.  
  8.             $values = $form->getValidValues($postData, true);
  9.  
  10.             // action with $values
  11.  
  12.             $db->commit();
  13.  
  14.             $this->_redirect('url');
  15.         } catch (Exception $e) {
  16.             $db->rollback();
  17.             throw $e;
  18.         }
  19.     } else {
  20.       // if action is edit
  21.       $form->populate($row->toArray());
  22.     }
  23. }
  24. $this->view->form = $form;