duang8642 2015-03-06 16:20 采纳率: 0%
浏览 71
已采纳

如何从runAction获取数据

I have this code in my view page:

<?php if(isset($journal)&&($keyword=="%")){
                            return Yii::$app->controller->runAction('journalslist',  ['publisherID'=>$journal['publisher_id'], 'partial'=>1]);
                    }

How can I get 'publisherID' and 'partial' in actionJournalList() in the controller?!!! var_dump($_POST) shows empty array and Yii::$app->getRequest()->getQueryParams() just have $_GET data? How can I config runAction to POST data?

Any help would be appreciated!

  • 写回答

2条回答 默认 最新

  • duanbogan5878 2015-03-08 00:51
    关注

    As far as I know there shouldn't really be a reason to ever call runAction explicitly as it does not match up with the MVC design.

    Explain what you're trying to achieve overall and you'll find a better answer. For now i'd say, look at the current controller/action that is rendering that view and have it check if(isset($journal)&&($keyword=="%")){ and route the information from the existing action to your view instead of trying to call a new action.

    Alternatively run a redirect.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?