/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
backend/forms/data/UserForm.php
109 строк
3 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace backend\forms\data; use common\forms\base\ObjectIdForm; use common\helpers\ArrayHelper; use common\kdf\KModelStatus; use common\models\Acl; use common\models\AclRole; use common\models\Email; use common\models\ModelAI; use common\models\SubjectArea; use common\models\Task; use common\models\User; use common\models\UserSubjectArea; use common\models\UserTask; use Yii; use yii\helpers\VarDumper; /** * Форма редактирования сервиса * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2024 */ class UserForm extends \common\forms\UserForm { /** * Подтверждение пароля * @var string */ public $password2 = null; /** * @inheritdoc */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [['password2'], 'string'], [ ['password2'], 'string', 'length' => [6, 24], ], [ 'password2', 'compare', 'compareAttribute' => 'password', 'message' => Yii::t('app', 'Password confirmation must match the password'), ], ]); } /** * @inheritdoc */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'password2' => Yii::t('app', 'Password confirmation'), ]); } /** * @inheritdoc */ public function loadModel($condition) { parent::loadModel($condition); $obj = User::findOne([ 'id' => $this->oid, ]); if ($obj) { if ($email = $obj->email) { $this->email = $email->value; } $this->role_id = Acl::find() ->select('role_id') ->andWhere([ 'user_id' => $obj->id ]) ->scalar() ?: null; $this->initState($obj); } } /** * @inheritdoc */ public function getPublicFields() { return ArrayHelper::merge(parent::getPublicFields(), [ 'display_name', 'username', 'email', 'role_id' => function () { return $this->prepareSelectField(AclRole::find(), 'role_id', 'title'); }, 'rec_status' => function () { return $this->prepareSelectField(KModelStatus::find(), 'rec_status', 'title'); }, ]); } }