mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-25 16:14:59 +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,
|
'label' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$builder->add('identifiers', PersonIdentifiersType::class, [
|
||||||
|
'by_reference' => false,
|
||||||
|
'step' => 'on_create',
|
||||||
|
]);
|
||||||
|
|
||||||
if ($this->askCenters) {
|
if ($this->askCenters) {
|
||||||
$builder
|
$builder
|
||||||
->add('center', PickCenterType::class, [
|
->add('center', PickCenterType::class, [
|
||||||
|
@@ -12,10 +12,12 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Form;
|
namespace Chill\PersonBundle\Form;
|
||||||
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
|
use Chill\PersonBundle\Entity\Identifier\IdentifierPresenceEnum;
|
||||||
use Chill\PersonBundle\Form\DataMapper\PersonIdentifiersDataMapper;
|
use Chill\PersonBundle\Form\DataMapper\PersonIdentifiersDataMapper;
|
||||||
use Chill\PersonBundle\PersonIdentifier\PersonIdentifierManagerInterface;
|
use Chill\PersonBundle\PersonIdentifier\PersonIdentifierManagerInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
final class PersonIdentifiersType extends AbstractType
|
final class PersonIdentifiersType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -32,6 +34,12 @@ final class PersonIdentifiersType extends AbstractType
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip some on creation
|
||||||
|
if ('on_create' === $options['step']
|
||||||
|
&& IdentifierPresenceEnum::ON_EDIT === $worker->getDefinition()->getPresence()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$subBuilder = $builder->create(
|
$subBuilder = $builder->create(
|
||||||
'identifier_'.$worker->getDefinition()->getId(),
|
'identifier_'.$worker->getDefinition()->getId(),
|
||||||
options: [
|
options: [
|
||||||
@@ -45,4 +53,10 @@ final class PersonIdentifiersType extends AbstractType
|
|||||||
|
|
||||||
$builder->setDataMapper($this->identifiersDataMapper);
|
$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>
|
<div data-suggest-container="{{ altName.vars.full_name|e('html_attr') }}" class="col-sm-8" style="margin-left: auto;"></div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% 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 }) }}
|
{{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user