$('#contact-form').yiiActiveForm('validate', true);
$('#deliveryForm .required input').on('blur',function(){
var id= $(this).attr('id');
$('#deliveryForm').yiiActiveForm('validateAttribute', id);
});
$('#deliveryForm .required input').on('blur',function(){
var id= $(this).attr('id');
$('#deliveryForm').yiiActiveForm('validateAttribute', id);
});
<?= $form->field($model, 'street')->textInput(); ?>
<div class="form-group field-order-street required">
<label class="control-label" for="order-street">Улица</label>
<input type="text" id="order-street" class="form-control" name="Order[street]" aria-required="true">
<p class="help-block help-block-error"></p>
</div>
$("#deliveryForm").yiiActiveForm("add", {
id: "order-street",
name: "Order[street]",
container: ".field-order-street",
input: "#order-street",
error: ".help-block",
validate: function (attribute, value, messages, deferred,$form ) {
yii.validation.required(value, messages, {message: "Validation Message Here"});
}
}); '
$('#deliveryForm').yiiActiveForm('validate', true);
$('#pjax-form-cart').on('load',function(){
$('#deliveryForm').yiiActiveForm();
});
и вот так тоже $('#pjax-form-cart').on('load',function(){
$('#deliveryForm').yiiActiveForm('validate', true);
});
<?php Pjax::begin(['id' => 'pjax-form-cart']); ?>
<div class="tab-content">
<div class="tab-pane delivery1 <?= ($userChoice==0)?'active':''?> ">
<?php if($userChoice==0){ echo PickUp::widget(['form'=>$form]); } ?>
</div>
<div class="tab-pane delivery2 <?= ($userChoice==1)?'active':''?>">
<?php if($userChoice==1){ echo DeliveryPiter::widget(['form'=>$form]); } ?>
</div>
</div>
<?php Pjax::end(); ?>
public function actionIndex(){
if(Yii::$app->request->isAjax &&isset($post['delivery']))
$this->userCartChoice($post['delivery']);
$choice= UserCartChoice::find()->one();
...
}
private function userCartChoice($choise){
$userChoise=UserCartChoice::find()->one();
if(!$userChoise)
$userChoise= new UserCartChoice();
$userChoise->choice=$choise;
$userChoise->save();
}
$('#deliveryForm .radio-tab input').change(function () {
var datas = $(this).val();
$.ajax({
method: "POST",
url: "/cart",
data: 'delivery='+datas,
success: function (data) {
$.pjax.reload({container: "#pjax-form-cart"});
$('#deliveryForm .radio-tabs .tab-pane').removeClass('active');
$('#deliveryForm .radio-tabs .tab-pane.delivery2').addClass('active');
}
})
});
получил string '1,2,3'