mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-25 08:05:00 +00:00
Add identifiers
field in CreationPersonType
and handle on_create
logic in PersonIdentifiersType
- Introduce `identifiers` field to `CreationPersonType` with a dedicated form type. - Update `PersonIdentifiersType` to support `step` option (`on_create` and `on_edit`). - Skip certain identifiers in `on_create` step based on presence configuration. - Adjust Twig template to display `identifiers` conditionally.
This commit is contained in:
@@ -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, [
|
||||
|
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
@@ -88,6 +88,15 @@
|
||||
<div data-suggest-container="{{ altName.vars.full_name|e('html_attr') }}" class="col-sm-8" style="margin-left: auto;"></div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if form.identifiers|length > 0 %}
|
||||
{% for f in form.identifiers %}
|
||||
<div class="row mb-1" style="display:flex;">
|
||||
{{ form_row(f) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{{ form_widget(form.identifiers) }}
|
||||
{% endif %}
|
||||
|
||||
{{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
|
||||
|
||||
|
Reference in New Issue
Block a user