Skip to content

Commit 3a2cd51

Browse files
committed
fix update permissions. #86 #77
1 parent 4e6d34c commit 3a2cd51

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

models/rbacDB/AbstractItem.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,15 @@ public function rules()
191191
*/
192192
public function validateUniqueName($attribute)
193193
{
194-
if ( Role::find()->where(['name'=>$this->name])->exists() )
194+
if ( $this->isNewRecord || ( $this->oldAttributes['name'] && $this->oldAttributes['name'] !== $this->name ) )
195195
{
196-
$this->addError('name', Yii::t('yii', '{attribute} "{value}" has already been taken.', [
197-
'attribute' => $this->getAttributeLabel($attribute),
198-
'value' => $this->$attribute,
199-
]));
196+
if ( Role::find()->where(['name'=>$this->name])->exists() )
197+
{
198+
$this->addError('name', Yii::t('yii', '{attribute} "{value}" has already been taken.', [
199+
'attribute' => $this->getAttributeLabel($attribute),
200+
'value' => $this->$attribute,
201+
]));
202+
}
200203
}
201204
}
202205

0 commit comments

Comments
 (0)