diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index e02b6e4c3..6db871e5b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; +use Chill\PersonBundle\Form\PersonResourceType; use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Repository\PersonResourceRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -30,13 +31,15 @@ final class PersonResourceController extends AbstractController public function listAction($person_id) { - dump($person_id); $person = $this->personRepository->find($person_id); - dump($person); + + $form = $this->createForm(PersonResourceType::class); + return $this->render( 'ChillPersonBundle:PersonResource:list.html.twig', [ - 'person' => $person + 'person' => $person, + 'form' => $form->createView() ] ); } diff --git a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php new file mode 100644 index 000000000..8863d705c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php @@ -0,0 +1,79 @@ +categoryRender = $categoryRender; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('kind', EntityType::class, [ + 'label' => 'Type', + 'required' => true, + 'class' => PersonResourceKind::class, + 'query_builder' => static function (EntityRepository $er) { + $qb = $er->createQueryBuilder('pr'); + $qb->where($qb->expr()->eq('pr.isActive', 'TRUE')); + return $qb; + }, + 'choice_label' => function (PersonResourceKind $personResourceKind) { + $options = []; + return $this->categoryRender->renderString($personResourceKind, $options); + } + ]) + ->add('linkedEntity', ChoiceType::class, [ + 'choices' => [ + 'Usager' => 'person', + 'Tiers' => 'thirdparty', + 'Description libre' => 'freeText' + ], + 'expanded' => true, + 'label' => 'Associer un' + ]) + ->add('comment', ChillTextareaType::class, [ + 'label' => 'Note', + 'required' => false + ]); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => PersonResource::class, + ]); + } + + // public function getBlockPrefix(): string + // { + // return 'chill_personbundle_personresource'; + // } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig new file mode 100644 index 000000000..9ba297d8b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig @@ -0,0 +1,24 @@ +
+ +

{{ 'Add a person resource'|trans }}

+ + {{ form_start(form, {'attr' : {'id' : 'create-form'}}) }} + + {{ form_row(form.kind) }} + + {{ form_row(form.linkedEntity) }} + + {{ form_row(form.comment) }} + + + + {{ form_end(form) }} + +
\ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig index 8e943c43a..b931c4f95 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -6,27 +6,29 @@ {% block personcontent %} -{{ person }}
-
Hello
-
there
+
Name of resource
+
kind of resource
-
+ {#
How
are
-
+
#}
-
you
+
comment zone
doing
-
today
-
?
+ {#
today
#} +
Buttons
+ +{% include "@ChillPerson/PersonResource/create.html.twig" %} + {% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index e2758034e..e7d4b3a1b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -223,7 +223,8 @@ The accompanying course has been successfully removed.: La période d'accompagne # person resource person_resources_menu: "Ressources" -Person resources: 'Réssources de la personne' +Person resources: "Réssources de la personne" +Add a person resource: "Ajouter une réssource" # pickAPersonType Pick a person: Choisir une personne