/** * @inheritdoc */ public function rules() { return [['status', 'default', 'value' => UserStatus::__default], ['status', 'in', 'range' => UserStatus::getValues()], [['email'], 'email'], [['profile_id'], 'integer'], ['profile_id', 'default', 'value' => \Yii::$app->params['generalProfileId']], [['username'], 'string', 'max' => 255], [['username', 'email'], 'required'], [['new_password', 'confirm_password'], 'string', 'min' => 6], [['confirm_password'], 'compare', 'compareAttribute' => 'new_password'], [['new_password', 'confirm_password'], 'required', 'when' => function ($model) { return $model->new_password != ''; }, 'whenClient' => "function (attribute, value) {\n return \$('#set-password').css('display') != 'none';\n }"]]; }
$form = ActiveForm::begin(['id' => 'user-form', 'layout' => 'horizontal']); ?> <?php echo $form->field($model, 'id')->textInput(['disabled' => true]); ?> <?php echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'profile_id')->dropDownList(\common\models\User::getTableProfile()); ?> <?php echo $form->field($model, 'status')->dropDownList(\common\enum\UserStatus::getList()); ?> <?php echo $form->field($model, 'email')->textInput(); ?> <div id="set-password" style="display: none;"> <?php echo $form->field($model, 'new_password')->passwordInput(); ?> <?php echo $form->field($model, 'confirm_password')->passwordInput(); ?>
?> <div style="margin-bottom: 5px"> <table width="100%"> <tbody> <tr> <td> <span class="pg-title">Utilizadores</span> </td> <td> <?php echo Html::a('Adicionar', ['create'], ['class' => 'btn btn-success pull-right']); ?> </td> </tr> </tbody> </table> </div> <div class="User-default-index"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $search, 'layout' => '{items}{pager}', 'columns' => ['id', 'username', ['attribute' => 'profile_id', 'format' => 'text', 'content' => function ($data) { return $data->profile->name; }], ['attribute' => 'status', 'format' => 'text', 'content' => function ($data) { return \common\enum\UserStatus::toName($data->status); }], 'email', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]); ?> </div>