mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Change PickGenderType form field to use in Person creation form
This commit is contained in:
@@ -996,7 +996,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->fullnameCanonical;
|
||||
}
|
||||
|
||||
public function getGender(): ?string
|
||||
public function getGender(): ?Gender
|
||||
{
|
||||
return $this->gender;
|
||||
}
|
||||
@@ -1525,7 +1525,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setGender(?string $gender): self
|
||||
public function setGender(?Gender $gender): self
|
||||
{
|
||||
$this->gender = $gender;
|
||||
|
||||
@@ -1650,16 +1650,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGenderKind(): ?Gender
|
||||
{
|
||||
return $this->genderKind;
|
||||
}
|
||||
|
||||
public function setGenderKind(?Gender $genderKind): void
|
||||
{
|
||||
$this->genderKind = $genderKind;
|
||||
}
|
||||
|
||||
private function getCurrentCenterHistory(): ?PersonCenterHistory
|
||||
{
|
||||
if (0 === $this->centerHistory->count()) {
|
||||
|
@@ -20,8 +20,8 @@ use Chill\MainBundle\Form\Type\PickCenterType;
|
||||
use Chill\MainBundle\Form\Type\PickCivilityType;
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\Type\GenderType;
|
||||
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
||||
use Chill\PersonBundle\Form\Type\PickGenderType;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use libphonenumber\PhoneNumberType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
@@ -60,7 +60,7 @@ final class CreationPersonType extends AbstractType
|
||||
'label' => 'Civility',
|
||||
'placeholder' => 'choose civility',
|
||||
])
|
||||
->add('gender', GenderType::class, [
|
||||
->add('gender', PickGenderType::class, [
|
||||
'required' => true, 'placeholder' => null,
|
||||
])
|
||||
->add('birthdate', ChillDateType::class, [
|
||||
|
@@ -24,9 +24,9 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\PersonPhone;
|
||||
use Chill\PersonBundle\Form\Type\GenderType;
|
||||
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
||||
use Chill\PersonBundle\Form\Type\PersonPhoneType;
|
||||
use Chill\PersonBundle\Form\Type\PickGenderType;
|
||||
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
@@ -80,7 +80,7 @@ class PersonType extends AbstractType
|
||||
'input' => 'datetime_immutable',
|
||||
'widget' => 'single_text',
|
||||
])
|
||||
->add('gender', GenderType::class, [
|
||||
->add('gender', PickGenderType::class, [
|
||||
'required' => true,
|
||||
])
|
||||
->add('genderComment', CommentType::class, [
|
||||
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Form\Type;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* A type to select the civil union state.
|
||||
*/
|
||||
class GenderType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$a = [
|
||||
Person::MALE_GENDER => Person::MALE_GENDER,
|
||||
Person::FEMALE_GENDER => Person::FEMALE_GENDER,
|
||||
Person::BOTH_GENDER => Person::BOTH_GENDER,
|
||||
];
|
||||
|
||||
$resolver->setDefaults([
|
||||
'choices' => $a,
|
||||
'expanded' => true,
|
||||
'multiple' => false,
|
||||
'placeholder' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return ChoiceType::class;
|
||||
}
|
||||
}
|
53
src/Bundle/ChillPersonBundle/Form/Type/PickGenderType.php
Normal file
53
src/Bundle/ChillPersonBundle/Form/Type/PickGenderType.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Form\Type;
|
||||
|
||||
use Chill\MainBundle\Entity\Gender;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* A type to select the civil union state.
|
||||
*/
|
||||
class PickGenderType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefault('label', 'Gender')
|
||||
->setDefault(
|
||||
'choice_label',
|
||||
fn (Gender $gender): string => $this->translatableStringHelper->localize($gender->getLabel())
|
||||
)
|
||||
->setDefault(
|
||||
'query_builder',
|
||||
static fn (EntityRepository $er): QueryBuilder => $er->createQueryBuilder('g')
|
||||
->where('g.active = true')
|
||||
->orderBy('g.order'),
|
||||
)
|
||||
->setDefault('placeholder', 'choose gender')
|
||||
->setDefault('class', Gender::class);
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
}
|
@@ -106,7 +106,7 @@
|
||||
{%- endif -%}
|
||||
{%- elseif person.birthdate is not null -%}
|
||||
<time datetime="{{ person.birthdate|date('Y-m-d') }}" title="{{ 'Birthdate'|trans }}">
|
||||
{{ 'Born the date'|trans({'gender': person.gender,
|
||||
{{ 'Born the date'|trans({'gender': person.gender.genderTranslation.value,
|
||||
'birthdate': person.birthdate|format_date("medium") }) }}
|
||||
</time>
|
||||
{%- if options['addAge'] -%}
|
||||
|
@@ -2,7 +2,7 @@ Born the date: >-
|
||||
{gender, select,
|
||||
man {Né le {birthdate}}
|
||||
woman {Née le {birthdate}}
|
||||
other {Né·e le {birthdate}}
|
||||
neutral {Né·e le {birthdate}}
|
||||
}
|
||||
|
||||
Requestor: >-
|
||||
|
Reference in New Issue
Block a user