kaynewilder
kaynewilder

Reputation: 853

Yii 2 Render Page Inside Tab Content

I have a Tabs widget:

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',
                 ],
            ],
        ],
    ],
]);

How do I render a page (without reloading the entire page, if possible) inside a Tab content? Is it possible? I tried this:

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

But it only generates this error:

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

If you have any idea how to deal with this, please let me know.

Upvotes: 2

Views: 10101

Answers (2)

BlackSkull
BlackSkull

Reputation: 193

try using Pjax widget. you can load a part of that content without reloading the whole page. but it will reload the whole page when it reach its timeout and it is still loading. check this guy's tutorial. http://blog.neattutorials.com/yii2-pjax-tutorial/

Upvotes: -1

topher
topher

Reputation: 14860

You are trying to pass a PHP expression where a string is required. yii\web\View::render() returns a string so your code should read:

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

Upvotes: 5

Related Questions