Hi all i’m using Kartik Detail View on my standard User model.
My field $user->email in the rules is of "email" type and is "unique" in the database.
I see in Edit-Mode that if i try to insert a wrong-mail i have the right error message.
If i try to insert an existing mail, i don’t have any error, but then when i save i have error on duplicate key.
I know that i must set “enableAjaxValidation” ON, but i don’t try where to set up in the Detail View.
Thank’s for any help.
EDIT
ok, as usually happend to me, first of all i search over the internet my problem solution or a way that help me.
If i don’t find, i write here.
In the while i’m waiting for any help, i study better each component and i find the solution by myself.
In this case, for future memory i add at the Detail View this configuration:
'formOptions'=>[
'enableAjaxValidation'=>true,
],
in the controller i add in the start of the action:
$check_user = new User();
if (Yii::$app->request->isAjax && $check_user->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($check_user);
}
remember to add these lines in the top of controller:
use yii\web\Response;
use yii\widgets\ActiveForm;
And now my Detail View works fine!