【问题标题】:Yii 2 Render Page Inside Tab ContentYii 2 在选项卡内容中渲染页面
【发布时间】:2015-04-19 01:19:49
【问题描述】:

我有一个标签小部件:

echo Tabs::widget([
    'items' => [
        [
            'label' => 'Add Staff', 
            'icon' => 'user',
            'content' => "Add Staff page loaded here",
            'active' => true
        ],
        [
            'label' => 'Store Configuration',
            'content' => 'Store Configuration page loaded here',
            //'headerOptions' => [...],
            'options' => ['id' => 'myveryownID'],
        ],
        [
            'label' => 'Transaction',
            'items' => [
                 [
                     'label' => 'Add Transaction',
                     'content' => 'Add Transaction page loaded here',
                 ],
                 [
                     'label' => 'View Transaction',
                     'content' => 'View Transaction page loaded here',
                 ],
            ],
        ],
    ],
]);

如何在选项卡内容中呈现页面(如果可能,无需重新加载整个页面)?可能吗?我试过这个:

'content' => "<?= $this->render('createbizstaff', ['searchModel' => $searchModel,'dataProvider' => $dataProvider,]); =>"

但它只会产生这个错误:

Getting unknown property: yii\web\View::render

如果您知道如何处理此问题,请告诉我。

【问题讨论】:

    标签: php tabs render yii2


    【解决方案1】:

    您正试图在需要字符串的地方传递 PHP 表达式。 yii\web\View::render() 返回一个字符串,因此您的代码应为:

    'content' => $this->render('createbizstaff', [
        'searchModel' => $searchModel,
        'dataProvider' => $dataProvider,
    ]),
    

    【讨论】:

      【解决方案2】:

      尝试使用 Pjax 小部件。您可以加载该内容的一部分,而无需重新加载整个页面。但它会在达到超时并且仍在加载时重新加载整个页面。 检查这个人的教程。 http://blog.neattutorials.com/yii2-pjax-tutorial/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多