yii2-bootstrap5 icon indicating copy to clipboard operation
yii2-bootstrap5 copied to clipboard

Added view option to render a view with Yii inside tab content

Open nilsburg opened this issue 1 year ago • 4 comments

Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Fixed issues

Adds the posibility to render a view inside a Tab content.

echo Tabs::widget([
    'items'   =>[
        [
            'label'   => 'Tab label',
            'view'    => ['@app/views/site/my-view',['param1'=>'value1']],
            'visible' => true,
        ],
    ],
]);

The main benefit is that when used with visible = false it won't render the view.

nilsburg avatar May 09 '24 14:05 nilsburg

is this really necessary? possible to do with

echo Tabs::widget([
    'items'   =>[
        [
            'label'   => 'Tab label',
            'content' => $this->render('@app/views/site/my-view', ['param1'=>'value1']),
            'visible' => true
        ]
    ]
]);

inside view, isn't it?

simialbi avatar Apr 10 '25 07:04 simialbi

Hi, the difference is that when using

echo Tabs::widget([
    'items'   =>[
        [
            'label'   => 'Tab label',
            'content' => $this->render('@app/views/site/my-view', ['param1'=>'value1']),
            'visible' => false
        ]
    ]
]);

The view will be rendered, even though visible is set to false.

nilsburg avatar Apr 10 '25 07:04 nilsburg

Ok so it would be some performance boots by preventing the rendering inside widget when visible false, correct?

simialbi avatar Apr 11 '25 09:04 simialbi

Not only performance, also to avoid code conflicts (some developer might put some JS in the view that overrides the JS in another view)

nilsburg avatar Apr 11 '25 10:04 nilsburg