where to put the submitButton in yii2 tab in case of deviding a form into multiple tabs

I have a form with many fields, on order to oragnize it I decided to divide it into multiple tabs using kartik tabX. I have divide my form view into many views that I call in the tab content property. My problem is the submit button. it is not working. I think I’m putting it in the wrong way.

Here is my code:

the views:


[*]the tab view:



<?=  TabsX::widget([

    'position' => TabsX::POS_ABOVE,

    'align' => TabsX::ALIGN_LEFT,


    'items' => [


            'label' => 'Informations générales',

            'content' => $this->render('_formInfoGeneralAcquisition', ['model' => $model,





            'active' => true,



            'label' => 'Amortissement',

            'content' => $this->render('_formAmortAcquisition', ['model' => $model,'compte'=>$compte]),

            'options' => ['id' => 'myveryownID'],





 <div class="form-group">

            <?= Html::SubmitButton( 'Enregistrer bien', ['class' => 'btn btn-success', 'id'=> 'm']) ?>    


 <?= Html::endForm();?>

_formInfoGeneralAcquisition view (first view):

<?php $form = ActiveForm::begin(['id' => 'acquisition-form']); ?>

//My fields

        <?php ActiveForm::end(); ?>

_formAmortAcquisition view (second view):

I have made the same thing for this second view.

<?php $form = ActiveForm::begin(['id' => 'acquisition-form']); ?>

//My fields

    <?php ActiveForm::end(); ?>

It looks like you have got multiple forms in one form and you try to submit the forms using the one big form submit button.

There are two solutions:

  1. Use js to send multiple forms by clicking "big form" submit button.

  2. Don’t wrap the tab view form fields in <form> tag so these can be taken as “big form” fields and therefor submitted with “big form” button.

Dear Bizley,

The problem is exactly as you mentionned. I get the data only from the first form and not from the other.

I tried the second solution but it is not working.

For the first solution ,I modified the forms IDs and I have added this js code to the tab view, but still not working.


$script = <<< JS

$(function () {