From 8049d3c774864d8b7eac5f10cac07770b91bd5dc Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 27 Oct 2016 01:22:39 +0300 Subject: [PATCH] =?UTF-8?q?=20=D0=A4=D0=B8=D0=BA=D1=81=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20=D1=81=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BD=D0=B8=D0=BA=D0=B0=20(=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BE=D0=BC=D0=B0=D0=BB=D0=B0=D1=81=D1=8C=20=D0=BB=D0=BE=D0=B3?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0,=20=D0=BA=D0=BE=D0=B3=D0=B4=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=20=D0=BD=D0=B5=20=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB?= =?UTF-8?q?=D1=81=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/models/profile/ChangeUsernameForm.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/models/profile/ChangeUsernameForm.php b/api/models/profile/ChangeUsernameForm.php index ef7f069..81f7957 100644 --- a/api/models/profile/ChangeUsernameForm.php +++ b/api/models/profile/ChangeUsernameForm.php @@ -30,7 +30,10 @@ class ChangeUsernameForm extends ApiForm { public function validateUsername($attribute) { $account = new Account(); + $account->id = $this->getAccount()->id; $account->username = $this->$attribute; + // Это чтобы unique validator учёл, что ник может быть забит на текущий аккаунт + $account->setIsNewRecord(false); if (!$account->validate(['username'])) { $this->addErrors($account->getErrors()); } @@ -46,7 +49,7 @@ class ChangeUsernameForm extends ApiForm { $oldNickname = $account->username; try { $account->username = $this->username; - if (!$account->save()) { + if (!$account->save(false)) { throw new ErrorException('Cannot save account model with new username'); }