Active Form Ajax Validation

if (Yii::$app->request->isAjax) { $model->load($_POST); Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } elseif ($model->load($_POST) && $model->save()) { return $this->redirect(['view', 'id' => $model['id']]); } else { return $this->render('update', [ 'model' => $model ]); }
<?php echo $form->field($model,'value')->begin(); ?> <?php echo Html::activeLabel($model,'value'); ?> <?php echo Html::activeTextInput($model,'value', ['maxlength'=>255, 'placeholder' => '123.456.78.9']); ?> <?php echo Html::error($model,'value', ['class' => 'help-block']); ?> <?php echo $form->field($model,'value')->end(); ?>