merge dynamic types

This commit is contained in:
Julien Fastré 2022-01-24 19:42:06 +01:00
parent 514d75fa5f
commit dec26e2ba4
2 changed files with 19 additions and 23 deletions

View File

@ -17,9 +17,11 @@ use Chill\MainBundle\Form\Type\CommentType;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Person\PersonResource; use Chill\PersonBundle\Entity\Person\PersonResource;
use Chill\PersonBundle\Entity\Person\PersonResourceKind; use Chill\PersonBundle\Entity\Person\PersonResourceKind;
use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
use Chill\PersonBundle\Templating\Entity\PersonRender; use Chill\PersonBundle\Templating\Entity\PersonRender;
use Chill\PersonBundle\Templating\Entity\ResourceKindRender; use Chill\PersonBundle\Templating\Entity\ResourceKindRender;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender; use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@ -63,25 +65,11 @@ final class PersonResourceType extends AbstractType
return $this->resourceKindRender->renderString($personResourceKind, $options); return $this->resourceKindRender->renderString($personResourceKind, $options);
} }
]) ])
->add('person', EntityType::class, [ ->add('person', PickPersonDynamicType::class, [
'label' => 'Usager', 'label' => 'Usager',
'class' => Person::class,
'placeholder' => $this->translator->trans('Select a person'),
'required' => false,
'choice_label' => function (Person $person) {
$options = [];
return $this->personRender->renderString($person, $options);
}
]) ])
->add('thirdparty', EntityType::class, [ ->add('thirdparty', PickThirdpartyDynamicType::class, [
'label' => 'Tiers', 'label' => 'Tiers',
'class' => ThirdParty::class,
'required' => false,
'placeholder' => $this->translator->trans('Select a thirdparty'),
'choice_label' => function (ThirdParty $thirdParty) {
$options = [];
return $this->thirdPartyRender->renderString($thirdParty, $options);
}
]) ])
->add('freetext', ChillTextareaType::class, [ ->add('freetext', ChillTextareaType::class, [
'label' => 'Description libre', 'label' => 'Description libre',
@ -105,4 +93,4 @@ final class PersonResourceType extends AbstractType
return 'chill_personbundle_person_resource'; return 'chill_personbundle_person_resource';
} }
} }

View File

@ -4,6 +4,20 @@
{% block title %}{{ 'Person resources'|trans|capitalize ~ ' ' ~ person|chill_entity_render_string }}{% endblock %} {% block title %}{{ 'Person resources'|trans|capitalize ~ ' ' ~ person|chill_entity_render_string }}{% endblock %}
{% block js %}
{{ encore_entry_script_tags('page_person_resource_person_input') }}
{{ encore_entry_script_tags('page_person_resource_thirdparty_input') }}
{{ encore_entry_script_tags('page_person_resource_freetext_input') }}
{{ encore_entry_script_tags('mod_pickentity_type') }}
{% endblock %}
{% block css %}
{{ encore_entry_link_tags('page_person_resource_person_input') }}
{{ encore_entry_link_tags('page_person_resource_thirdparty_input') }}
{{ encore_entry_link_tags('page_person_resource_freetext_input') }}
{{ encore_entry_link_tags('mod_pickentity_type') }}
{% endblock %}
{% block personcontent %} {% block personcontent %}
<h1>{{ 'List of resources'|trans }}</h1> <h1>{{ 'List of resources'|trans }}</h1>
@ -91,9 +105,3 @@
{% include "@ChillPerson/PersonResource/create.html.twig" %} {% include "@ChillPerson/PersonResource/create.html.twig" %}
{% endblock %} {% endblock %}
{% block js %}
{{ encore_entry_script_tags('page_person_resource_person_input') }}
{{ encore_entry_script_tags('page_person_resource_thirdparty_input') }}
{{ encore_entry_script_tags('page_person_resource_freetext_input') }}
{% endblock %}