here are the model validation rules
public function rules() { return [ [['user_id', 'city_id', 'payment',], 'required'], ['street', 'required', 'message' => 'Укажите название улицы.'], ... ]; } that's how I create a form
<div class="radio radio-tab"> <label><input id="delivery1" type="radio" name="Order[delivery]" checked="" value="0"> Самовывоз </label> </div> <div class="radio radio-tab"> <label> <input id="delivery2" type="radio" name="Order[delivery]" value="1"> Доставка </label> </div> <div class="tab-content"> <div class="tab-pane delivery1 active"> ... </div> <div class="tab-pane delivery2"> </div> ... </div> <?php ActiveForm::end(); ?> thus form ajax request
$('.radio-tab input').change(function () { var id = $(this).attr('id'); if(id=='delivery1'){ ... }) if(id=='delivery2') $.ajax({ method: "POST", url: "/cart/delivery", data: true, success: function (data) { ... $('.radio-tabs .tab-pane.delivery2').html(data); $('.radio-tabs .tab-pane.delivery2').addClass('active'); } }) so I process it in the controller
public function actionDelivery(){ $model=new Order(); return $this->renderAjax('_deliveryPiter',[ 'model'=>$model, ]); } and so I deduce
... <div class="col-xs-12 col-sm-4"> <div class="form-group field-order-street <?= $model->isAttributeRequired('street') ? 'required' : '' ?>"> <?= Html::activeLabel($model,'street'); ?> <?= Html::activeInput('text',$model,'street',['class'=>'form-control']) ?> </div> ... </div> and everything seems to be displayed but the question with validation on the client remains open. That is, if the input is not completed, an error message is not displayed, and an incorrectly completed form is sent to the server where, respectively, validation on the server does not pass. The question is how you can organize the e-mail on the client.