PJAX multiple blocks

Hello I have a problem

I’m place 2 forms per page, with pjax apdates…

both work if I place that single. But whenever try place both… replaced only second form.

look at my controller.

use Yii;

use yii\web\Controller;

use app\modules\studio\models\Leads;

use yii\helpers\Url;

class DefaultController extends Controller


    public function actionIndex()


        $model = new Leads();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {

            $post = Yii::$app->request->post('Leads');

            if( $post['request'] == '70% discount' ){

                return '<p>Sended</p>';

            }elseif ( $post['request'] == 'contact' ) {

                return '<h3 class="complete">Well Done.</h3>';


        } else {

            return $this->render('index', [

                'model' => $model,





and part of view

<section class="sale">

    <?php Pjax::begin(); ?>

        <?php $form = ActiveForm::begin(['options' => ['data' => ['pjax' => true]],]); ?>

            <?= $form->field($model, 'email')->textInput(['placeholder' => "your@mail.com"])->label(false); ?>

            <?= $form->field($model, 'request')->hiddenInput(['value'=> '70% discount'])->label(false); ?>

            <?= Html::submitButton('Take it', ['class' => 'mybtn']) ?>

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

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


<section class="contact">

    <?php Pjax::begin(); ?>

        <?php $form = ActiveForm::begin(['options' => ['data' => ['pjax' => true]],]); ?>

            <?= $form->field($model, 'phone')->textInput(['placeholder' => "+1 (123) 456-78-90"]) ?>

            <?= $form->field($model, 'request')->hiddenInput(['value'=> 'contact'])->label(false); ?>

            <?= Html::submitButton('Send', ['class' => 'mybtn']) ?>

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

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


when I try submit "contact" form, content of that pjax block updated perfectly. But when submitting "sale" form, after reload, full content change to response content (without layout).

Both pjax forms works if that single at page.

Help me please some one

P.S. Sry for my English.

Pjax is not a replacement for ajax and it is not designed to be used as multiple Pjax widgets in one page.

Pjax will update the URL of the page when a part of the page changes, if you have two widgets you have two possible URLs to display in the browser. this conflicts and does not work.

And what’s solution?

Need add custom AJAX send form at JS?

Thanks for answer.

if you do not need URL rewrite, just use normal AJAX request.