fix double person creation + button for creating accompanying course on creation + simplification person create

The controller now register data from a previous post on the form, and
register it in the session.

The next post compare the data with previous one and, if yes, show a
review page if there are "alternate persons.
This commit is contained in:
2021-08-23 17:42:08 +02:00
parent c798b1290c
commit 8fb4a7110e
8 changed files with 217 additions and 338 deletions

View File

@@ -20,27 +20,70 @@
{% block content %}
<div class="col-md-10 col-xxl person-new">
<h1>{{ 'Add a person'|trans }}</h1>
{% if alternatePersons is not empty %}
<div class="alert alert-warning flash_message">
<span>
{% transchoice alternatePersons|length with { '%nb%': alternatePersons|length } %}
%nb% person with similar name. Please verify that this is a new person
{% endtranschoice %}
</span>
</div>
<table class="table table-bordered border-dark">
<thead>
<tr>
<th class="chill-red">{{ 'Name'|trans }}</th>
<th class="chill-green">{{ 'Date of birth'|trans }}</th>
<th class="chill-orange">{{ 'Nationality'|trans }}</th>
</tr>
</thead>
<tbody>
{% for person in alternatePersons %}
<tr>
<td>
<a href="{{ path('chill_person_view', {'person_id': person.id } ) }}">
{{ person|chill_entity_render_string }}{% apply spaceless %}
{% if person.isOpen == false %}
<i class="icon-lock"></i>
{% endif %}
{% endapply %}
</a>
</td>
<td>{% if person.birthdate is not null %}{{ person.birthdate|format_date('long') }}{% else %}&nbsp;{% endif %}</td>
<td>
{% if person.nationality is not null %}{{ person.nationality.name|localize_translatable_string }}{% else %}{{ 'Without nationality'|trans }}{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{{ form_start(form) }}
<h1>{{ 'Add a person'|trans }}</h1>
{{ form_row(form.firstName, { 'label' : 'First name'|trans }) }}
{{ form_row(form.firstName, { 'label' : 'First name'|trans }) }}
{{ form_row(form.lastName, { 'label' : 'Last name'|trans }) }}
{{ form_row(form.lastName, { 'label' : 'Last name'|trans }) }}
{% if form.altNames is defined %}
{{ form_widget(form.altNames) }}
{% endif %}
{% if form.altNames is defined %}
{{ form_widget(form.altNames) }}
{% endif %}
{{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }}
{{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }}
{{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
{{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
{{ form_rest(form) }}
<button class="btn btn-create" type="submit" alt="add a person">
{{ 'Add the person'|trans }}
</button>
<ul class="record_actions sticky-form-buttons">
<li>
{{ form_widget(form.editPerson, { 'attr': { 'class': 'btn btn-create' }}) }}
</li>
<li>
{{ form_widget(form.createPeriod, { 'attr': { 'class': 'btn btn-create' }}) }}
</li>
</ul>
{{ form_end(form) }}