:::

3-2 編輯活動表單

  1. 讀出資料
    action/AdminAction.class.php
    if (isset($_GET['action_id'])) {
    $_OneAction = $this->_action->findOne();
    $this->_tpl->assign('next_op', "update");
    } else {
    $_OneAction['enable'] = 1;
    $this->_tpl->assign('next_op', "add");
    }
    $this->_tpl->assign("OneAction", $_OneAction);
    
    

     

  2. 加入編輯
    action/AdminAction.class.php
    if ($_POST['next_op'] == "update") {
                        if ($this->_action->actions_update()) {
                            $_message = "修改成功!";
                        } else {
                            $_message = "修改失敗!";
                        }
    
                    }

     

  3. model/ActionsModel.class.php
    public function actions_update($_selectData = array())
        {
            $_where = array("action_id='{$this->_R['action_id']}'");
    
            if (!$this->_check->oneCheck($this, $_where)) {
                return;
            }
    
            if (!$this->_check->addCheck($this)) {
                return;
            }
    
            $_selectData = empty($_selectData) ? $this->_fields : $_selectData;
            $_updateData = $this->getRequest()->filter($_selectData);
    
            parent::update($_where, $_updateData);
            return $this->_R['action_id'];
        }
     
  4. 修改樣板
    templates/op_actions_form.tpl
    <input type="hidden" name="action_id" value="<{$OneAction.action_id}>">