Exemplo n.º 1
0
 public function editAction()
 {
     $authorization = Zend_Auth::getInstance();
     $identity = $authorization->getIdentity();
     if ($identity->user_type == "admin") {
         $form = new Application_Form_Course();
         $model = new Application_Model_Courses();
         $id = $this->getRequest()->getParam('id');
         $course_data = $model->getCourseById($id);
         $category_model = new Application_Model_Categories();
         $categories = $category_model->listCategories();
         for ($i = 0; $i < count($categories); $i++) {
             $options[$categories[$i]['id']] = $categories[$i]['name'];
         }
         $form->getElement('catid')->setMultiOptions($options);
         var_dump($course_data);
         $form->populate($course_data[0]);
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->getRequest()->getParams())) {
                 $model = new Application_Model_Courses();
                 $model->editCourse($form->getValues(), $id);
                 //$this->view->identity->id
                 $this->redirect("/courses/list");
             }
         }
         $this->view->form = $form;
         $this->render("add");
     } else {
         $this->redirect("cources/index");
     }
 }
Exemplo n.º 2
0
 public function editAction()
 {
     $form = new Application_Form_Course();
     $model = new Application_Model_Courses();
     //$this->view->courses  = $model->editCourse();
     $id = $this->getRequest()->getParam('id');
     $course_data = $model->getCourseById($id);
     $form->populate($course_data);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams())) {
             $model = new Application_Model_Courses();
             $model->editCourse($form->getValues(), 1);
             //$this->view->identity->id
             $this->_redirect("/courses/list");
         }
     }
     $this->view->{$form} = $form;
     $this->render('add');
 }