public function validatePermission() { if (!$this->hasErrors()) { $auth = \App::$app->getAuthManager(); if ($this->isNewRecord && $auth->getPermission($this->name)) { $this->addError('name', \App::t('auth', 'This name already exists.')); } if ($this->isNewRecord && $auth->getRole($this->name)) { $this->addError('name', \App::t('auth', 'This name already exists.')); } } }
/** * @inheritdoc */ public function attributeLabels() { $labels = parent::attributeLabels(); return array_merge($labels, ['password' => \App::t('app', 'Password'), 'repassword' => \App::t('app', 'Repassword')]); }