person: Person FormType + edit twig

This commit is contained in:
nobohan 2021-06-17 12:27:47 +02:00
parent 901ae47ce6
commit 8406c30c8e
3 changed files with 46 additions and 5 deletions

View File

@ -34,9 +34,12 @@ use Chill\PersonBundle\Entity\PersonPhone;
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
use Symfony\Component\Form\AbstractType;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\CommentType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -82,8 +85,17 @@ class PersonType extends AbstractType
->add('birthdate', ChillDateType::class, [
'required' => false,
])
->add('deathdate', ChillDateType::class, [
'required' => false,
])
->add('gender', GenderType::class, array(
'required' => true
))
->add('genderComment', CommentType::class, array(
'required' => false
))
->add('numberOfChildren', IntegerType::class, array(
'required' => false
));
if ($this->configAltNamesHelper->hasAltNames()) {
@ -111,7 +123,12 @@ class PersonType extends AbstractType
}
if ($this->config['mobilenumber'] === 'visible') {
$builder->add('mobilenumber', TelType::class, array('required' => false));
$builder
->add('mobilenumber', TelType::class, array('required' => false))
->add('acceptSMS', CheckboxType::class, array(
'value' => false,
'required' => true //TODO required only if mobilenumber is filled
));
}
$builder->add('otherPhoneNumbers', ChillCollectionType::class, [
@ -130,7 +147,9 @@ class PersonType extends AbstractType
]);
if ($this->config['email'] === 'visible') {
$builder->add('email', EmailType::class, array('required' => false));
$builder
->add('email', EmailType::class, array('required' => false))
->add('acceptEmail', CheckboxType::class, array('required' => false));//TODO visible only if email is filled
}
if ($this->config['country_of_birth'] === 'visible') {
@ -153,7 +172,14 @@ class PersonType extends AbstractType
}
if ($this->config['marital_status'] === 'visible'){
$builder->add('maritalStatus', Select2MaritalStatusType::class, array(
$builder
->add('maritalStatus', Select2MaritalStatusType::class, array(
'required' => false
))
->add('maritalStatusDate', ChillDateType::class, array(
'required' => false
))
->add('maritalStatusComment', CommentType::class, array(
'required' => false
));
}

View File

@ -43,6 +43,7 @@
{{ form_widget(form.altNames, { 'label': 'Alternative names'}) }}
{% endif %}
{{ form_row(form.gender, {'label' : 'Gender'}) }}
{{ form_row(form.genderComment, { 'label' : 'Comment on the gender'} ) }}
</fieldset>
<fieldset>
@ -54,6 +55,9 @@
{%- if form.countryOfBirth is defined -%}
{{ form_row(form.countryOfBirth, { 'label' : 'Country of birth' } ) }}
{%- endif -%}
{%- if form.deathdate is defined -%}
{{ form_row(form.deathdate, { 'label' : 'Date of death' } ) }}
{%- endif -%}
</fieldset>
{%- if form.nationality is defined or form.spokenLanguages is defined or form.maritalStatus is defined -%}
@ -65,8 +69,11 @@
{%- if form.spokenLanguages is defined -%}
{{ form_row(form.spokenLanguages, {'label' : 'Spoken languages'}) }}
{%- endif -%}
{{ form_row(form.numberOfChildren, {'label' : 'Number of children'}) }}
{%- if form.maritalStatus is defined -%}
{{ form_row(form.maritalStatus, { 'label' : 'Marital status'} ) }}
{{ form_row(form.maritalStatusDate, { 'label' : 'Date of last marital status change'} ) }}
{{ form_row(form.maritalStatusComment, { 'label' : 'Comment on the marital status'} ) }}
{%- endif -%}
</fieldset>
{%- endif -%}
@ -76,12 +83,14 @@
<legend><h2>{{ 'Contact information'|trans }}</h2></legend>
{%- if form.email is defined -%}
{{ form_row(form.email, {'label': 'Email'}) }}
{{ form_row(form.acceptEmail, {'label' : 'Accept emails ?'}) }}
{%- endif -%}
{%- if form.phonenumber is defined -%}
{{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }}
{%- endif -%}
{%- if form.mobilenumber is defined -%}
{{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }}
{{ form_row(form.acceptSMS, {'label' : 'Accept short text message ?'}) }}
{%- endif -%}
{%- if form.otherPhoneNumbers is defined -%}
{{ form_widget(form.otherPhoneNumbers) }}

View File

@ -10,6 +10,8 @@ First name or Last name: Prénom ou nom
id: identifiant
Birthdate: 'Date de naissance'
birthdate: date de naissance
deathdate: date de décès
Date of death: Date de décès
'Date of birth': 'Date de naissance'
dateOfBirth: date de naissance
dateofbirth: date de naissance
@ -30,16 +32,20 @@ placeOfBirth: lieu de naissance
countryOfBirth: 'Pays de naissance'
'Unknown country of birth': 'Pays inconnu'
'Marital status': 'État civil'
Date of last marital status change: État civil depuis le
Comment on the marital status: Commentaires sur l'état civil
'Number of children': 'Nombre d''enfants'
'{0} No child|{1} One child | ]1,Inf] %nb% children': '{0} Aucun enfant|{1} Un enfant | ]1,Inf] %nb% enfants'
'National number': 'Numéro national'
Email: 'Courrier électronique'
Accept emails ?: Accepte les courriels?
Address: Adresse
Memo: Mémo
Phonenumber: 'Numéro de téléphone'
phonenumber: numéro de téléphone
Mobilenumber: 'Numéro de téléphone portable'
mobilenumber: numéro de téléphone portable
Accept short text message ?: Accepte les SMS?
Other phonenumber: Autre numéro de téléphone
Description: description
Add new phone: Ajouter un numéro de téléphone