Split ActiveForm in different tabs

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(); ?>



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!

great :)

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

                    ],

                    ],

                    ]);?>