Pro pole name
1) Model.php
[['name'], 'unique'],
или
[['name'], 'unique', 'filter' => 'is_delete = "0"'],
2) Controller.php
use yii\web\Response;
use yii\widgets\ActiveForm;
...
public function actionCreate()
{
$model = new Product();
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post())) {
...
...
public function actionUpdate($id)
{
$model = $this->findModel($id);
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post())) {
...
3) V _form.php
...
<?php $form = ActiveForm::begin(['enableAjaxValidation' => true]); ?>
...