mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
extends User entity + alter admin (WIP)
This commit is contained in:
27
src/Bundle/ChillMainBundle/Form/UserJobType.php
Normal file
27
src/Bundle/ChillMainBundle/Form/UserJobType.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class UserJobType extends \Symfony\Component\Form\AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('label', TranslatableStringFormType::class, [
|
||||
'label' => 'Label',
|
||||
'required' => true
|
||||
])
|
||||
->add('active', ChoiceType::class, [
|
||||
'choices' => [
|
||||
'Active' => true,
|
||||
'Inactive' => false
|
||||
]
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
}
|
@@ -2,7 +2,15 @@
|
||||
|
||||
namespace Chill\MainBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
@@ -16,6 +24,16 @@ use Chill\MainBundle\Form\UserPasswordType;
|
||||
|
||||
class UserType extends AbstractType
|
||||
{
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
/**
|
||||
* @param TranslatableStringHelper $translatableStringHelper
|
||||
*/
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
@@ -24,7 +42,40 @@ class UserType extends AbstractType
|
||||
{
|
||||
$builder
|
||||
->add('username')
|
||||
->add('email')
|
||||
->add('email', EmailType::class, [
|
||||
'required' => true
|
||||
])
|
||||
->add('label', TextType::class)
|
||||
->add('mainCenter', EntityType::class, [
|
||||
'label' => 'main center',
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a main center',
|
||||
'class' => Center::class,
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('c');
|
||||
$qb->addOrderBy('c.name');
|
||||
|
||||
return $qb;
|
||||
}
|
||||
])
|
||||
->add('mainScope', EntityType::class, [
|
||||
'label' => 'Choose a main scope',
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a main scope',
|
||||
'class' => Scope::class,
|
||||
'choice_label' => function (Scope $c) {
|
||||
return $this->translatableStringHelper->localize($c->getName());
|
||||
},
|
||||
])
|
||||
->add('userJob', EntityType::class, [
|
||||
'label' => 'Choose a job',
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a job',
|
||||
'class' => UserJob::class,
|
||||
'choice_label' => function (UserJob $c) {
|
||||
return $this->translatableStringHelper->localize($c->getLabel());
|
||||
},
|
||||
])
|
||||
;
|
||||
if ($options['is_creation']) {
|
||||
$builder->add('plainPassword', RepeatedType::class, array(
|
||||
|
Reference in New Issue
Block a user