diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php index bb40c6c35..83e811eac 100644 --- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php @@ -89,6 +89,11 @@ final class CreationPersonType extends AbstractType 'label' => false, ]); + $builder->add('identifiers', PersonIdentifiersType::class, [ + 'by_reference' => false, + 'step' => 'on_create', + ]); + if ($this->askCenters) { $builder ->add('center', PickCenterType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/PersonIdentifiersType.php b/src/Bundle/ChillPersonBundle/Form/PersonIdentifiersType.php index ea077f626..0ab057280 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonIdentifiersType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonIdentifiersType.php @@ -12,10 +12,12 @@ declare(strict_types=1); namespace Chill\PersonBundle\Form; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Chill\PersonBundle\Entity\Identifier\IdentifierPresenceEnum; use Chill\PersonBundle\Form\DataMapper\PersonIdentifiersDataMapper; use Chill\PersonBundle\PersonIdentifier\PersonIdentifierManagerInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; final class PersonIdentifiersType extends AbstractType { @@ -32,6 +34,12 @@ final class PersonIdentifiersType extends AbstractType continue; } + // skip some on creation + if ('on_create' === $options['step'] + && IdentifierPresenceEnum::ON_EDIT === $worker->getDefinition()->getPresence()) { + continue; + } + $subBuilder = $builder->create( 'identifier_'.$worker->getDefinition()->getId(), options: [ @@ -45,4 +53,10 @@ final class PersonIdentifiersType extends AbstractType $builder->setDataMapper($this->identifiersDataMapper); } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefault('step', 'on_edit') + ->setAllowedValues('step', ['on_edit', 'on_create']); + } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig index 1ceb84395..5a17acf18 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig @@ -88,6 +88,15 @@
{% endfor %} {% endif %} + {% if form.identifiers|length > 0 %} + {% for f in form.identifiers %} +
+ {{ form_row(f) }} +
+ {% endfor %} + {% else %} + {{ form_widget(form.identifiers) }} + {% endif %} {{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}