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