Skip to content

Commit e3b940f

Browse files
committed
Fix #16
1 parent 6896a8a commit e3b940f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/controllers/ItemController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function actionSave()
8282
{
8383
$item = null;
8484

85-
if (isset($_POST['ItemForm']['oldName'])) {
85+
if (isset($_POST['ItemForm']['oldName']) && $_POST['ItemForm']['oldName'] !== '') {
8686
$item = $this->findItem($_POST['ItemForm']['oldName']);
8787
}
8888

src/models/ItemForm.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ public function rules()
7676
[['name', 'type'], 'required'],
7777
[
7878
['name'],
79-
'unique',
79+
'uniqueName',
8080
'when' => function () {
8181
return $this->isNewRecord;
8282
}
8383
],
8484
[
8585
['oldName'],
86-
'unique',
86+
'uniqueName',
8787
'when' => function () {
8888
return !$this->isNewRecord && $this->name != $this->oldName;
8989
}
@@ -94,7 +94,7 @@ public function rules()
9494
];
9595
}
9696

97-
public function unique()
97+
public function uniqueName()
9898
{
9999
$authManager = Yii::$app->authManager;
100100
$value = $this->name;

0 commit comments

Comments
 (0)