mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-09 10:26:14 +00:00
allow age calculation on NULL birthdate and allow age to be null
+ improve translation of age
This commit is contained in:
parent
08e396195c
commit
76e7f5b1ee
@ -0,0 +1,6 @@
|
|||||||
|
years_old: >-
|
||||||
|
{age, plural,
|
||||||
|
one {# an}
|
||||||
|
many {# ans}
|
||||||
|
other {# ans}
|
||||||
|
}
|
@ -734,9 +734,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
return $this->birthdate;
|
return $this->birthdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAge(): int
|
public function getAge(): ?int
|
||||||
{
|
{
|
||||||
return date_diff($this->birthdate, date_create('now'))->format("%y");
|
if ($this->birthdate instanceof \DateTimeInterface) {
|
||||||
|
return date_diff($this->birthdate, date_create('now'))->format("%y");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,10 +76,10 @@
|
|||||||
{{ 'Unknown date of birth'|trans }}
|
{{ 'Unknown date of birth'|trans }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ person.birthdate|format_date('short') }}
|
{{ person.birthdate|format_date('short') }}
|
||||||
|
<span class="age">
|
||||||
|
{{ 'years_old'|trans({ 'age': person.age }) }}
|
||||||
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="age">
|
|
||||||
{{ person.age ~ ((person.age > 1) ? ' ans' : ' an') }}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{%- if chill_person.fields.nationality == 'visible' -%}
|
{%- if chill_person.fields.nationality == 'visible' -%}
|
||||||
|
@ -102,7 +102,7 @@ class PersonControllerUpdateTest extends WebTestCase
|
|||||||
public function testHiddenFielsArePresent()
|
public function testHiddenFielsArePresent()
|
||||||
{
|
{
|
||||||
$crawler = $this->client->request('GET', $this->editUrl);
|
$crawler = $this->client->request('GET', $this->editUrl);
|
||||||
|
var_dump($crawler->text());
|
||||||
$configurables = array('placeOfBirth', 'phonenumber', 'email',
|
$configurables = array('placeOfBirth', 'phonenumber', 'email',
|
||||||
'countryOfBirth', 'nationality', 'spokenLanguages', 'maritalStatus');
|
'countryOfBirth', 'nationality', 'spokenLanguages', 'maritalStatus');
|
||||||
$form = $crawler->selectButton('Enregistrer')->form(); //;
|
$form = $crawler->selectButton('Enregistrer')->form(); //;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user