2018-04-26 11:38:52 2024次浏览 3条回答 0 悬赏 30 金钱

同一个控制器,如何将另一个的action 传那个value去 actionindex? / 另外一个action 可以直接传那个数据去 template?

  • 回答于 2018-04-26 14:49 举报

    问题本身就是个问题

    觉得很赞
  • 回答于 2018-04-26 17:07 举报

    yii2 redirect() 方法

    3 条回复
    回复于 2018-04-27 13:42 回复

    不小心发到2 个 不好意识

    回复于 2018-04-27 13:42 回复

    我刚刚用了 render 返回数据了,如果我有actionindex和 actiontest, 如果我想把actiontest 把数据返回 actionindex 可以用redirect?

    回复于 2018-04-28 09:20 回复

    $this->redirect(['user/view', 'id' => $id]);

  • 回答于 2018-05-03 20:52 举报

    控制器中$this->run($route, $params = []) 可以调用另一个action
    例:ueditor插件中

    `public function actionIndex() {

        $request = Yii::$app->getRequest();
        $method = $request->get('action');
        $callback = $request->get('callback');
        if (in_array($method, ['config', 'uploadimage', 'uploadscrawl', 'uploadvideo', 'uploadfile', 'listimage', 'listfile', 'catchimage'])) {
            return $this->run($method);
        }
        return $this->show(['state' => '请求地址出错']);
    }
    
    public function actionUploadimage() {
        $setting = $this->config();
        $config = [
          "pathFormat" => $setting['imagePathFormat'],
          "maxSize" => $setting['imageMaxSize'],
          "allowFiles" => $setting['imageAllowFiles']
        ];
        $res = $this->_upload($setting['imageFieldName'], $config, 'upload');
        return $this->show($res);
    }
    

    `

您需要登录后才可以回答。登录 | 立即注册
adriantango
经理

adriantango 马来西亚

注册时间:2018-03-08
最后登录:2018-05-22
在线时长:13小时25分
  • 粉丝4
  • 金钱985
  • 威望0
  • 积分1115

热门问题