arreglado bug al crear usuario

This commit is contained in:
2024-03-15 09:22:32 +01:00
parent d31986cf19
commit 6626c1aedf
3 changed files with 35 additions and 34 deletions

View File

@ -69,7 +69,8 @@ class Users extends \App\Controllers\GoBaseController {
$postData['password'] = $phpass->HashPassword($this->request->getPost('password'));
}
$currentGroups = $postData['group'];
$currentGroups = $postData['group']??[];
unset($postData['group']);
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
@ -133,7 +134,7 @@ class Users extends \App\Controllers\GoBaseController {
$this->viewData['formAction'] = route_to('createUser');
$this->viewData['groups'] = $this->group_model->select('token,title')->findAll();
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' Users.php' .lang('Users.user').' '.lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') .lang('Users.user').' '.lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
@ -238,7 +239,7 @@ class Users extends \App\Controllers\GoBaseController {
$this->viewData['selectedGroups'] = $this->group_user_model->select('token_group')->where('token_user', $user->token)->findAll();
$this->viewData['groups'] = $this->group_model->select('token,title')->findAll();
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' Users.php' .lang('Users.user').' '.lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') .lang('Users.user').' '.lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);

View File

@ -60,7 +60,7 @@ class UserModel extends \App\Models\GoBaseModel
],
"country" => [
"label" => "Users.country",
"rules" => "trim|required|max_length[2]",
"rules" => "trim|max_length[2]",
],
"date_birth" => [
"label" => "Users.dateBirth",
@ -76,11 +76,11 @@ class UserModel extends \App\Models\GoBaseModel
],
"first_name" => [
"label" => "Users.firstName",
"rules" => "trim|required|max_length[150]",
"rules" => "trim|max_length[150]",
],
"language" => [
"label" => "Users.language",
"rules" => "trim|required|max_length[10]",
"rules" => "trim|max_length[10]",
],/*
"last_access" => [
"label" => "Users.lastAccess",
@ -92,11 +92,11 @@ class UserModel extends \App\Models\GoBaseModel
],
"last_name" => [
"label" => "Users.lastName",
"rules" => "trim|required|max_length[150]",
"rules" => "trim|max_length[150]",
],
"mobile" => [
"label" => "Users.mobile",
"rules" => "trim|required|max_length[50]",
"rules" => "trim|max_length[50]",
],
"password" => [
"label" => "Users.password",
@ -104,7 +104,7 @@ class UserModel extends \App\Models\GoBaseModel
],
"picture" => [
"label" => "Users.picture",
"rules" => "trim|required|max_length[150]",
"rules" => "trim|max_length[150]",
],
"state" => [
"label" => "Users.state",

View File

@ -3,31 +3,31 @@
<div class="mb-3">
<label for="firstName" class="form-label">
<?=lang('Users.firstName') ?>*
<?=lang('Users.firstName') ?>
</label>
<input type="text" id="firstName" name="first_name" required maxLength="150" class="form-control" value="<?=old('first_name', $user->first_name) ?>">
<input tabindex="1" type="text" id="firstName" name="first_name" maxLength="150" class="form-control" value="<?=old('first_name', $user->first_name) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="address" class="form-label">
<?=lang('Users.address') ?>
</label>
<input type="text" id="address" name="address" maxLength="255" class="form-control" value="<?=old('address', $user->address) ?>">
<input tabindex="3" type="text" id="address" name="address" maxLength="255" class="form-control" value="<?=old('address', $user->address) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="state" class="form-label">
<?=lang('Users.state') ?>*
<?=lang('Users.state') ?>
</label>
<input type="text" id="state" name="state" maxLength="255" class="form-control" value="<?=old('state', $user->state) ?>">
<input tabindex="5" type="text" id="state" name="state" maxLength="255" class="form-control" value="<?=old('state', $user->state) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="country" class="form-label">
<?=lang('Users.country') ?>*
<?=lang('Users.country') ?>
</label>
<select id="country" name="country" required class="select2 form-control " style="width: 100%;" >
<select tabindex="7" id="country" name="country" class="select2 form-control " style="width: 100%;" >
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('Users.country')]) ?></option>
<?php foreach ($paisList as $item) : ?>
@ -42,35 +42,35 @@
<label for="dateBirth" class="form-label">
<?=lang('Users.dateBirth') ?>
</label>
<input type="date" id="dateBirth" name="date_birth" maxLength="10" class="form-control" value="<?=old('date_birth', $user->date_birth) ?>">
<input tabindex="9" type="date" id="dateBirth" name="date_birth" maxLength="10" class="form-control" value="<?=old('date_birth', $user->date_birth) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="mobile" class="form-label">
<?=lang('Users.mobile') ?>*
<?=lang('Users.mobile') ?>
</label>
<input type="text" id="mobile" name="mobile" maxLength="50" class="form-control" value="<?=old('mobile', $user->mobile) ?>">
<input tabindex="11" type="text" id="mobile" name="mobile" maxLength="50" class="form-control" value="<?=old('mobile', $user->mobile) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="email" class="form-label">
<?=lang('Users.email') ?>*
</label>
<input type="email" id="email" name="email" required maxLength="150" class="form-control" value="<?=old('email', $user->email) ?>">
<input tabindex="13" type="email" id="email" name="email" maxLength="150" class="form-control" value="<?=old('email', $user->email) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="password" class="form-label">
<?=lang('Users.password') ?>*
</label>
<input type="password" id="password" name="password" maxLength="35" class="form-control" value="<?=old('password', $user->password) ?>">
<input tabindex="15" type="password" id="password" name="password" maxLength="35" class="form-control" value="<?=old('password', $user->password) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-group">
<label for="group" class="form-label"> <?=lang('Users.group') ?></label>
<select name="group[]" id="group" multiple="multiple" class="form-control select2 form-select">
<select tabindex="17" name="group[]" id="group" multiple="multiple" class="form-control select2 form-select">
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('Users.group')]) ?></option>
<?php foreach ($groups as $item) : ?>
<?php if (isset($selectedGroups) && sizeof($selectedGroups)>=1): ?>
@ -93,30 +93,30 @@
<div class="mb-3">
<label for="lastName" class="form-label">
<?=lang('Users.lastName') ?>*
<?=lang('Users.lastName') ?>
</label>
<input type="text" id="lastName" name="last_name" required maxLength="150" class="form-control" value="<?=old('last_name', $user->last_name) ?>">
<input tabindex="2" type="text" id="lastName" name="last_name" maxLength="150" class="form-control" value="<?=old('last_name', $user->last_name) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="city" class="form-label">
<?=lang('Users.city') ?>
</label>
<input type="text" id="city" name="city" maxLength="255" class="form-control" value="<?=old('city', $user->city) ?>">
<input tabindex="4" type="text" id="city" name="city" maxLength="255" class="form-control" value="<?=old('city', $user->city) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="zipCode" class="form-label">
<?=lang('Users.zipCode') ?>
</label>
<input type="text" id="zipCode" name="zip_code" maxLength="50" class="form-control" value="<?=old('zip_code', $user->zip_code) ?>">
<input tabindex="6" type="text" id="zipCode" name="zip_code" maxLength="50" class="form-control" value="<?=old('zip_code', $user->zip_code) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-group">
<label for="language" class="text-dark"><?=lang("Users.language")?></label>
<?php $id_select = old('language', $user->language);?>
<select name="language" id="language" class="form-control">
<select tabindex="8" name="language" id="language" class="form-control">
<option value=""><?=lang("App.global_select")?></option>
<option value="en" <?= $id_select == "en" ? 'selected' : '' ?>><?=lang("App.lang_en")?></option>
<option value="es" <?= $id_select == "es" ? 'selected' : '' ?>><?=lang("App.lang_es")?></option>
@ -126,17 +126,17 @@
<div class="mb-3">
<label for="picture" class="form-label">
<?=lang('Users.picture') ?>*
<?=lang('Users.picture') ?>
</label>
<input type="text" id="picture" name="picture" required placeholder="/assets/img/default-user.png" maxLength="150" class="form-control" value="<?=old('picture', $user->picture) ?>">
<input tabindex="10" type="text" id="picture" name="picture" placeholder="/assets/img/default-user.png" maxLength="150" class="form-control" value="<?=old('picture', $user->picture) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="blocked" class="form-label">
<?=lang('Users.blocked') ?>*
<?=lang('Users.blocked') ?>
</label>
<?php $id_select = old('blocked', $user->blocked);?>
<select name="blocked" id="blocked" class="select2 form-control">
<select tabindex="12" name="blocked" id="blocked" class="select2 form-control">
<option value="0" <?= $id_select == "0" ? 'selected' : '' ?>><?=lang("Users.non_blocked")?></option>
<option value="1" <?= $id_select == "1" ? 'selected' : '' ?>><?=lang("Users.blocked")?></option>
</select>
@ -147,7 +147,7 @@
<?=lang('Users.emailConfirmed') ?>*
</label>
<?php $id_select = old('email_confirmed', $user->email_confirmed);?>
<select name="email_confirmed" id="email_confirmed" class="select2 form-control">
<select tabindex="14" name="email_confirmed" id="email_confirmed" class="select2 form-control">
<option value="0" <?= $id_select == "0" ? 'selected' : '' ?>><?=lang("Users.email_not_confirmed")?></option>
<option value="1" <?= $id_select == "1" ? 'selected' : '' ?>><?=lang("Users.email_confirmed")?></option>
</select>
@ -157,10 +157,10 @@
<div class="mb-3">
<label for="status" class="form-label">
<?=lang('Users.status') ?>*
<?=lang('Users.status') ?>
</label>
<?php $id_select = old('status', $user->status);?>
<select name="status" id="status" class="select2 form-control">
<select tabindex="16" name="status" id="status" class="select2 form-control">
<option value="1" <?= $id_select == "1" ? 'selected' : '' ?>><?=lang("Users.global_active")?></option>
<option value="0" <?= $id_select == "0" ? 'selected' : '' ?>><?=lang("Users.global_inactive")?></option>
</select>