mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
person: fix adding civility to a person with OnTheFly form
This commit is contained in:
parent
7a2151f23a
commit
7d3239d6d6
@ -87,7 +87,7 @@
|
|||||||
<label>{{ $t('person.gender.title') }}</label>
|
<label>{{ $t('person.gender.title') }}</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-floating mb-3">
|
<div v-if="action === 'create'" class="form-floating mb-3">
|
||||||
<select
|
<select
|
||||||
class="form-select form-select-lg"
|
class="form-select form-select-lg"
|
||||||
id="civility"
|
id="civility"
|
||||||
@ -187,8 +187,8 @@ export default {
|
|||||||
get() { return this.person.gender; }
|
get() { return this.person.gender; }
|
||||||
},
|
},
|
||||||
civility: {
|
civility: {
|
||||||
set(value) { this.person.civility = value; },
|
set(value) { this.person.civility = {id: value}; },
|
||||||
get() { return this.person.civility; }
|
get() { return this.person.civility ? this.person.civility.id : undefined; }
|
||||||
},
|
},
|
||||||
birthDate: {
|
birthDate: {
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -12,7 +12,9 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
|
use Chill\MainBundle\Entity\Civility;
|
||||||
use Chill\MainBundle\Phonenumber\PhoneNumberHelperInterface;
|
use Chill\MainBundle\Phonenumber\PhoneNumberHelperInterface;
|
||||||
|
use Chill\MainBundle\Repository\CivilityRepository;
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
|
use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
@ -54,6 +56,8 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
|||||||
|
|
||||||
private PersonRepository $repository;
|
private PersonRepository $repository;
|
||||||
|
|
||||||
|
private CivilityRepository $civilityRepository;
|
||||||
|
|
||||||
private ResidentialAddressRepository $residentialAddressRepository;
|
private ResidentialAddressRepository $residentialAddressRepository;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@ -61,12 +65,14 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
|||||||
PersonRepository $repository,
|
PersonRepository $repository,
|
||||||
CenterResolverManagerInterface $centerResolverManager,
|
CenterResolverManagerInterface $centerResolverManager,
|
||||||
ResidentialAddressRepository $residentialAddressRepository,
|
ResidentialAddressRepository $residentialAddressRepository,
|
||||||
|
CivilityRepository $civilityRepository,
|
||||||
PhoneNumberHelperInterface $phoneNumberHelper /* TODO maybe not necessayr any more */
|
PhoneNumberHelperInterface $phoneNumberHelper /* TODO maybe not necessayr any more */
|
||||||
) {
|
) {
|
||||||
$this->render = $render;
|
$this->render = $render;
|
||||||
$this->repository = $repository;
|
$this->repository = $repository;
|
||||||
$this->centerResolverManager = $centerResolverManager;
|
$this->centerResolverManager = $centerResolverManager;
|
||||||
$this->residentialAddressRepository = $residentialAddressRepository;
|
$this->residentialAddressRepository = $residentialAddressRepository;
|
||||||
|
$this->civilityRepository = $civilityRepository;
|
||||||
$this->phoneNumberHelper = $phoneNumberHelper;
|
$this->phoneNumberHelper = $phoneNumberHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +107,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
|||||||
'center',
|
'center',
|
||||||
'altNames',
|
'altNames',
|
||||||
'email',
|
'email',
|
||||||
|
'civility'
|
||||||
];
|
];
|
||||||
|
|
||||||
$fields = array_filter(
|
$fields = array_filter(
|
||||||
@ -176,6 +183,14 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
|||||||
case 'email':
|
case 'email':
|
||||||
$person->setEmail($data[$item]);
|
$person->setEmail($data[$item]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'civility':
|
||||||
|
//$civility = $this->denormalizer->denormalize($data[$item], Civility::class, $format, $context); // this seems the right way to do it, but this does not render a Civility object.
|
||||||
|
$civility = $this->civilityRepository->findOneBy(['id' => $data[$item]['id']]);
|
||||||
|
|
||||||
|
$person->setCivility($civility);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user