Ejemplo n.º 1
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be reload the page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $sectionModel = $this->loadModel($id);
     $sectionTextModel = new SectionText();
     if ($sectionModel->sectionTexts) {
         $sectionTextModel = SectionText::findOne($sectionModel->sectionTexts[0]->SectionTextId);
     }
     $sectionList = $this->getSectionList();
     if (Yii::$app->request->post()) {
         $form = Yii::$app->request->post("SectionText");
         if (DataManagement::updateSection($form['Name'], $sectionTextModel, $id)) {
             $this->redirect(["index"]);
         }
     }
     return $this->render("index", ["sectionModel" => $sectionModel, "sectiontextModel" => $sectionTextModel, "sectionList" => $sectionList]);
 }
Ejemplo n.º 2
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be reload the page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate()
 {
     $id = Yii::$app->request->get("id", 0);
     $pageNo = Yii::$app->request->get("pno", 0);
     $topicForm = new TopicForm();
     $topicModel = $this->loadModel($id);
     $topicList = [];
     $editTopic = 1;
     $topicForm->section = $topicModel->section->sectionTexts[0]->Name;
     $topicForm->title = $topicModel->topicTexts[0]->Title;
     $topicForm->body = $topicModel->topicTexts[0]->Body;
     if (!empty($topicModel->parent)) {
         $topicForm->parent = $topicModel->parent->topicTexts[0]->Title;
     } else {
         $topicForm->parent = "No Parent";
     }
     $topicTextId = $topicModel->topicTexts[0]->TopicTextId;
     if (Yii::$app->request->isPost) {
         $request = Yii::$app->request;
         $form = $request->post('TopicForm');
         $topicForm->body = trim($form['body']);
         $topicForm->title = trim($form['title']);
         if ($topicForm->validate()) {
             $textModel = TopicText::findOne($topicTextId);
             if (DataManagement::updateTopic($topicForm, $textModel)) {
                 $this->redirect(Url::to(['/helpsystem/admin/topic/index', 'page' => $pageNo, 'sectionId' => $topicModel->SectionId]));
             }
         }
     }
     return $this->render("create", ['topicList' => $topicList, 'topicForm' => $topicForm, 'editTopic' => $editTopic]);
 }