Пример #1
0
 /**
  * Edit a set
  *
  * @return void
  */
 public function editsetAction()
 {
     $request = $this->getRequest();
     $id = $this->_helper->IdConvert->hexToStr($request->getParam('id'));
     if (empty($id)) {
         $this->_helper->messenger->error('Nie podano parametru ID');
         return $this->_helper->redirector('index');
     }
     $set = $this->_model->getSet($id)->toArray();
     if ($set['api']) {
         $set['shipping_type'][] = Logic_Ws_ServiceSet_ServiceSet::SHIPPING_TYPE_API;
     }
     if ($set['http']) {
         $set['shipping_type'][] = Logic_Ws_ServiceSet_ServiceSet::SHIPPING_TYPE_HTTP;
     }
     $form = new Logic_Ws_ServiceSet_Form_Add();
     if ($request->isPost()) {
         if ($form->isCancelled($this->getRequest()->getPost())) {
             $this->_helper->redirector('index', null, null);
             return;
         } elseif ($form->isValid($request->getPost())) {
             try {
                 $values = $form->getValues();
                 $this->_model->updateSet($values, $id);
                 $this->_helper->messenger->success();
                 $this->_helper->redirector('index');
                 return;
             } catch (Logic_Ws_Exception $e) {
                 $this->_helper->messenger->error();
             }
         }
     } else {
         $form->setDefaults($set);
     }
     $this->view->form = $form;
 }