yii2mod / yii2-rbac

RBAC Manager for Yii 2
MIT License
145 stars 58 forks source link

Error When Create New Role or Permission #22

Closed bahirul closed 6 years ago

bahirul commented 6 years ago

Get this error whene create new role or permission :

TypeError

Argument 1 passed to yii2mod\rbac\models\AuthItemModel::find() must be of the type string, none given, called in /var/www/html/payroll-ns/vendor/yiisoft/yii2/validators/UniqueValidator.php on line 210

I think the problem is unique function in AuthItemModel. You use unique validator, but unique ini yii2 use built ini yii2/validators/UniqueValidator.php.

It will be better renaming custom validation function, uniqueRole as example.

ihorchepurnyi commented 6 years ago

Hi, thanks, I will check it.

ihorchepurnyi commented 6 years ago

I fixed this issue, please update your package.

bahirul commented 6 years ago

Hi @igor-chepurnoi, thanks for fixing this issue.

asilvestre87 commented 6 years ago

Hi @igor-chepurnoi, I have similar issue, but to me it returns the next error:

Call to undefined method yii2mod\rbac\models\AuthItemModel::getDb()

in /var/www/DST-tool/vendor/yiisoft/yii2/validators/UniqueValidator.php at line 139

    foreach ($rawConditions as $key => $value) {
        if (is_array($value)) {
            $this->addError($model, $attribute, Yii::t('yii', '{attribute} is invalid.'));
            return;
        }
        $conditions[] = [$key => $value];
    }

    $db = $targetClass::getDb(); ****this line is the problem

......

Edit: Sorry, the problem is because when i install module through composer, it is not install the last version of module.