function addAction()
 {
     $this->view->title = "Add New Product";
     $form = new ProductForm();
     $form->submit->setLabel('Add');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $products = new Product();
             $row = $products->createRow();
             $row->product_name = $form->getValue('product_name');
             $row->product_id = $form->getValue('product_id');
             $row->product_desc = $form->getValue('product_desc');
             $row->category_id = $form->getValue('category_id');
             $row->product_image = $form->getValue('product_image');
             $row->save();
             $this->_redirect('/');
         } else {
             $form->populate($formData);
         }
     }
 }
Example #2
0
 function adminaddgiftAction()
 {
     $this->_helper->layout->setLayout("layout_admin");
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         //Zend_Debug::dump($formData);
         $productModel = new Product();
         $product = $productModel->createRow();
         $product->name = $formData['name'];
         $product->point = $formData['point'];
         $product->state = $formData['state'];
         $product->source = $formData['source'];
         $product->category = $formData['category'];
         $product->subcategory = $formData['subcategory'];
         $product->description = $formData['description'];
         $product->url = $formData['url'];
         $product->long_desc = $formData['long_desc'];
         $product->save();
         $this->view->saved = true;
     } else {
         $fc = Zend_Controller_Front::getInstance();
         $this->view->oFCKeditor = new FCKeditor("long_desc");
         $this->view->oFCKeditor->BasePath = $fc->getBaseUrl() . "/js/fckeditor/";
         $this->view->oFCKeditor->Height = "500px";
         if ($this->view->product['long_desc'] != null && $this->view->product['long_desc'] != '') {
             $this->view->oFCKeditor->Value = $this->view->product['long_desc'];
         }
     }
 }