Fix using of user scenarios

This commit is contained in:
Yuriy Bakhtin 2023-09-19 17:27:27 +02:00
parent 5d651e38e6
commit d0c2de9f46
3 changed files with 5 additions and 5 deletions

View File

@ -111,7 +111,7 @@ class UserController extends Controller
$canEditAdminFields = Yii::$app->user->isAdmin() || !$user->isSystemAdmin();
$canEditPassword = $canEditAdminFields && $authClientUserService->canChangePassword();
$user->scenario = 'editAdmin';
$user->scenario = User::SCENARIO_EDIT_ADMIN;
$user->profile->scenario = Profile::SCENARIO_EDIT_ADMIN;
$profile = $user->profile;

View File

@ -46,7 +46,7 @@ class UserEditForm extends User
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['editAdmin'][] = 'groupSelection';
$scenarios[static::SCENARIO_EDIT_ADMIN][] = 'groupSelection';
return $scenarios;
}

View File

@ -160,18 +160,18 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
}],
[['created_by', 'updated_by'], 'integer'],
[['status'], 'in', 'range' => array_keys(self::getStatusOptions())],
[['visibility'], 'in', 'range' => array_keys(self::getVisibilityOptions()), 'on' => Profile::SCENARIO_EDIT_ADMIN],
[['visibility'], 'in', 'range' => array_keys(self::getVisibilityOptions()), 'on' => static::SCENARIO_EDIT_ADMIN],
[['tagsField', 'blockedUsersField'], 'safe'],
[['guid'], 'string', 'max' => 45],
[['time_zone'], 'validateTimeZone'],
[['auth_mode'], 'string', 'max' => 10],
[['language'], 'string', 'max' => 5],
['language', 'in', 'range' => array_keys(Yii::$app->i18n->getAllowedLanguages()), 'except' => self::SCENARIO_APPROVE],
['language', 'in', 'range' => array_keys(Yii::$app->i18n->getAllowedLanguages()), 'except' => static::SCENARIO_APPROVE],
[['email'], 'unique'],
[['email'], 'email'],
[['email'], 'string', 'max' => 150],
[['guid'], 'unique'],
[['username'], 'validateForbiddenUsername', 'on' => [self::SCENARIO_REGISTRATION]],
[['username'], 'validateForbiddenUsername', 'on' => [static::SCENARIO_REGISTRATION]],
];
if ($this->isEmailRequired()) { // HForm does not support 'required' in combination with 'when'.