public function editAction() { $this->checkLogin(); $form = new PAP_Form_PromotionForm(); $this->view->form = $form; $user = $this->_helper->Session->getUserSession(); $this->loadPriceRules($user); if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); $data['userId'] = $user->getId(); $data['branches'] = $_POST['branches']; $newPromotion = new PAP_Model_Promotion(); $newPromotion->update($data); $this->saveImages($data, $newPromotion); //$this->loadForm($newPromotion, 'update'); $this->_redirect('promotion/index'); } } else { $promotion = new PAP_Model_Promotion(); $promo_id = $this->getParam('id'); $promotionMapper = new PAP_Model_PromotionMapper(); $promotionMapper->find($promo_id, $promotion); if (isset($promotion)) { $this->loadForm($promotion, 'update'); //TODO Modificar la carga de Branches cuando sean màs de uno. //$this->_helper->Session->setBranchSession($branch); } else { //@todo Mostrar mensaje de que no se encontrò la promo. } } $this->loadUserBranches($this->user); }