mirror of
https://github.com/kevinpapst/kimai2.git
synced 2025-04-02 04:27:56 +00:00
include roles and teams in user create form
This commit is contained in:
parent
9226daa891
commit
8e1a148275
3 changed files with 85 additions and 0 deletions
|
@ -241,6 +241,8 @@ final class UserController extends AbstractController
|
|||
'include_active_flag' => true,
|
||||
'include_preferences' => $this->isGranted('preferences', $user),
|
||||
'include_add_more' => true,
|
||||
'include_teams' => $this->isGranted('teams_other_profile'),
|
||||
'include_roles' => $this->isGranted('roles_other_profile'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\Type\TeamType;
|
||||
use App\Form\Type\UserRoleType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
|
@ -42,6 +44,24 @@ class UserCreateType extends UserEditType
|
|||
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
if ($options['include_teams'] === true) {
|
||||
$builder
|
||||
->add('teams', TeamType::class, [
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($options['include_roles'] === true) {
|
||||
$builder
|
||||
->add('roles', UserRoleType::class, [
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($options['include_add_more'] === true) {
|
||||
$builder->add('create_more', CheckboxType::class, [
|
||||
'label' => 'label.create_more',
|
||||
|
@ -58,6 +78,8 @@ class UserCreateType extends UserEditType
|
|||
$resolver->setDefaults([
|
||||
'validation_groups' => ['UserCreate', 'Registration'],
|
||||
'include_add_more' => false,
|
||||
'include_roles' => false,
|
||||
'include_teams' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,67 @@
|
|||
} %}
|
||||
{% embed formEditTemplate with formOptions %}
|
||||
{% block form_body %}
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
{{ form_row(form.username) }}
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
{{ form_row(form.email) }}
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
{{ form_row(form.color) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
{{ form_row(form.alias) }}
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
{{ form_row(form.title) }}
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
{{ form_row(form.accountNumber) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ form_row(form.plainPassword.first) }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{{ form_row(form.plainPassword.second) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ form_row(form.language) }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{{ form_row(form.timezone) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if form.teams is defined or form.roles is defined %}
|
||||
{% set length = 12 %}
|
||||
{% if form.teams is defined and form.roles is defined %}
|
||||
{% set length = 6 %}
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
{% if form.teams is defined %}
|
||||
<div class="col-md-{{ length }}">
|
||||
{{ form_row(form.teams) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if form.roles is defined %}
|
||||
<div class="col-md-{{ length }}">
|
||||
{{ form_row(form.roles) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{ form_widget(form) }}
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
|
|
Loading…
Add table
Reference in a new issue