Skip to content

Commit

Permalink
Fix #16
Browse files Browse the repository at this point in the history
  • Loading branch information
githubjeka committed Jan 29, 2019
1 parent 6896a8a commit e3b940f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function actionSave()
{
$item = null;

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

Expand Down
6 changes: 3 additions & 3 deletions src/models/ItemForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ public function rules()
[['name', 'type'], 'required'],
[
['name'],
'unique',
'uniqueName',
'when' => function () {
return $this->isNewRecord;
}
],
[
['oldName'],
'unique',
'uniqueName',
'when' => function () {
return !$this->isNewRecord && $this->name != $this->oldName;
}
Expand All @@ -94,7 +94,7 @@ public function rules()
];
}

public function unique()
public function uniqueName()
{
$authManager = Yii::$app->authManager;
$value = $this->name;
Expand Down

0 comments on commit e3b940f

Please sign in to comment.