From a24cd693e3e4176a45b35dafe8b79bbcaef877bc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 14 Mar 2022 10:23:47 +0100 Subject: [PATCH] firstname field added to twig form for child or contact types --- .../Entity/ThirdParty.php | 35 ++++++++----------- .../Form/ThirdPartyType.php | 4 +++ .../views/ThirdParty/_form.html.twig | 4 +++ .../_form_thirdparty_children.html.twig | 5 +++ .../Resources/views/ThirdParty/view.html.twig | 2 +- .../translations/messages.fr.yml | 1 + 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index db56dbd94..6e30c40dc 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -463,12 +463,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->email; } - /** - * Get id. - * - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } @@ -478,16 +473,16 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->kind; } - /** - * Get name. - * - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } + public function getFirstname(): string + { + return $this->firstname; + } + public function getNameCompany(): ?string { return $this->nameCompany; @@ -782,20 +777,20 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } - /** - * Set name. - * - * @param string $name - * - * @return ThirdParty - */ - public function setName($name) + public function setName($name): self { $this->name = $name; return $this; } + public function setFirstname($firstname): self + { + $this->firstname = $firstname; + + return $this; + } + /** * @param string $nameCompany */ diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 480808dfe..28e87c584 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -102,6 +102,10 @@ class ThirdPartyType extends AbstractType // Contact Person ThirdParty (child) if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) { $builder + ->add('firstname', TextType::class, [ + 'label' => 'firstname', + 'required' => true, + ]) ->add('civility', PickCivilityType::class, [ 'label' => 'thirdparty.Civility', 'placeholder' => 'thirdparty.choose civility', diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig index 4827ba19c..fffa44a6a 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig @@ -3,6 +3,10 @@ {{ form_row(form.civility) }} {% endif %} +{% if form.firstname is defined %} +{{ form_row(form.firstname) }} +{% endif %} + {{ form_row(form.name) }} {% if form.nameCompany is defined %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig index eac5c2a98..cffbf0ad7 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig @@ -7,6 +7,11 @@ {{ form_errors(form.civility) }} {{ form_label(form.civility) }} +
+ {{ form_widget(form.firstname) }} + {{ form_errors(form.firstname) }} + {{ form_label(form.firstname) }} +
{{ form_widget(form.name) }} {{ form_errors(form.name) }} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig index c4f2bcfbd..3dac7a0dd 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig @@ -25,7 +25,7 @@
{{ 'Name'|trans }}
{% if thirdParty.isLeaf == true %}{{ thirdParty.civility }}{% endif %} - {{ thirdParty.name }} + {{ thirdParty.firstname ~ ' ' ~ thirdParty.name }}
{% if thirdParty.kind == 'company' %} diff --git a/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml b/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml index 20b45a398..4607f5ba9 100644 --- a/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml @@ -1,6 +1,7 @@ Third party: Tiers Third parties: Tiers third parties: tiers +firstname: Prénom name: Nom telephone: Téléphone adress: Adresse