Exemplo n.º 1
0
 public function addAction()
 {
     // action body
     $cat_arr = $this->getCategoriesArray();
     $prodform = new Application_Form_Product();
     $catName = $prodform->getElement('catid');
     foreach ($cat_arr as $id => $name) {
         $catName->addMultiOption($id, $name);
     }
     $this->view->prodform = $prodform;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getAllParams())) {
             $new_image_name = time() . '_' . $this->getParam('name');
             $upload = new Zend_File_Transfer_Adapter_Http();
             $upload->addFilter('Rename', APPLICATION_PATH . '/../public/img/product/' . $new_image_name);
             $upload->receive();
             $form_data = $form->getValues();
             $model = new Application_Model_Product();
             $form_data['picture'] = $new_image_name;
             $da = $model->addProduct($form_data);
             $this->redirect('Product/list');
         }
     }
 }