AleCat83
(Alessandro Cattaneo83)
February 5, 2015, 11:03am
1
Hello there,
I have a view with a long activeForm and many activeFields.
Is it possible to group in tabs the activeFields?
I’ve read about the TabsWidget but it seems possible only to specify static tabs content in the [items] options.
Someone can help me?
Thank you
Alessandro
Hi, try to use this code:
<?php $form = ActiveForm::begin(); ?>
echo Tabs::widget([
'items' => [
[
'label' => 'One',
'content' => $this->render('_form', ['form' => $form]),
'active' => true
],
[
'label' => 'Two',
'content' => $this->render('_form2', ['form' => $form]),
],
],
]);
<?php ActiveForm::end(); ?>
AleCat83
(Alessandro Cattaneo83)
February 6, 2015, 5:11pm
3
Hi,
Thank you very much! It worked!
I’ve done only one change: added the “model” => $model parameter when calling render on the sub form, in order to send the $model for active fields init.
echo Tabs::widget([
'items' => [
[
'label' => 'One',
'content' => $this->render('_form_tab1', ['form' => $form, "model" => $model]),
'active' => true
],
[
'label' => 'Two',
'content' => $this->render('_form_tab2', ['form' => $form, "model" => $model]),
],
],
]);
Thank you!
LucasK
(Igor90riv)
July 16, 2016, 11:50am
5
AleCat83:
Hi,
Thank you very much! It worked!
I’ve done only one change: added the “model” => $model parameter when calling render on the sub form, in order to send the $model for active fields init.
…
Thank you!
Thx, worked this variant:
<?= Tabs::widget([
'items' => [
[
'label' => 'Create article',
'content' => $this->render('_form-create-article', ['model' => $model_create_article]),
'active' => true
],
[
'label' => 'Order article',
'content' => $this->render('_form-order-article', ['model' => $model_order_article]),
],
],
]);?>