mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
take parameter form_show_center
into account: not to ask center on person creation
This commit is contained in:
@@ -25,6 +25,7 @@ use Chill\MainBundle\Form\Event\CustomizeFormEvent;
|
||||
use Chill\MainBundle\Repository\CenterRepository;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -54,14 +55,18 @@ final class CreationPersonType extends AbstractType
|
||||
|
||||
private EventDispatcherInterface $dispatcher;
|
||||
|
||||
private bool $askCenters;
|
||||
|
||||
public function __construct(
|
||||
CenterRepository $centerRepository,
|
||||
ConfigPersonAltNamesHelper $configPersonAltNamesHelper,
|
||||
EventDispatcherInterface $dispatcher
|
||||
EventDispatcherInterface $dispatcher,
|
||||
ParameterBagInterface $parameterBag
|
||||
) {
|
||||
$this->centerTransformer = $centerRepository;
|
||||
$this->configPersonAltNamesHelper = $configPersonAltNamesHelper;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->askCenters = $parameterBag->get('chill_main')['acl']['form_show_centers'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,12 +83,15 @@ final class CreationPersonType extends AbstractType
|
||||
])
|
||||
->add('gender', GenderType::class, array(
|
||||
'required' => true, 'placeholder' => null
|
||||
))
|
||||
->add('center', PickCenterType::class, [
|
||||
'required' => false,
|
||||
'role' => PersonVoter::CREATE,
|
||||
])
|
||||
;
|
||||
));
|
||||
|
||||
if ($this->askCenters) {
|
||||
$builder
|
||||
->add('center', PickCenterType::class, [
|
||||
'required' => false,
|
||||
'role' => PersonVoter::CREATE,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->configPersonAltNamesHelper->hasAltNames()) {
|
||||
$builder->add('altNames', PersonAltNameType::class, [
|
||||
|
Reference in New Issue
Block a user