some improvement to the Update / create event pages

- i18n of all the form
- add a title to each page
- chill layout of each page
- add flash message on successfully creation and update action

For the update page, (see #23), the user is not allowed to update
the center

close #23
close #2
This commit is contained in:
Julien Fastré 2016-03-24 23:00:45 +01:00
parent cf7f8a929b
commit c9ce3aca96
5 changed files with 61 additions and 20 deletions

View File

@ -42,6 +42,9 @@ class EventController extends Controller
$em->persist($entity);
$em->flush();
$this->addFlash('success', $this->get('translator')
->trans('The event was created'));
return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId())));
}
@ -186,6 +189,7 @@ class EventController extends Controller
'method' => 'PUT',
));
$form->remove('center');
$form->add('submit', 'submit', array('label' => 'Update'));
@ -212,6 +216,9 @@ class EventController extends Controller
if ($editForm->isValid()) {
$em->flush();
$this->addFlash('success', $this->get('translator')
->trans('The event was updated'));
return $this->redirect($this->generateUrl('chill_event__event_edit', array('event_id' => $event_id)));
}

View File

@ -1,5 +1,6 @@
#events
Name: Nom
Label: Nom
Date: Date
Event type : Type d'événement
See: Voir
@ -14,6 +15,12 @@ Last update: Dernière mise à jour
#CRUD event
Details of an event: Détails d'un événement
New event: Nouvel événement
Back to the most recent events: Retour aux derniers événements
Event creation: Création d'un événement
Add an event: Ajouter un événement
Event edit: Modifier un événement
The event was updated: L'événement a été modifié
The event was created: L'événement a été créé
#crud participation
Edit all the participations: Modifier toutes les participations

View File

@ -1,16 +1,30 @@
{% extends 'ChillEventBundle::layout.html.twig' %}
{% block event_content -%}
<h1>Event edit</h1>
{% block title 'Event edit'|trans %}
{{ form(edit_form) }}
{% block event_content -%}
<h1>{{ 'Event edit'|trans }}</h1>
{{ form_start(edit_form) }}
{{ form_errors(edit_form) }}
{{ form_row(edit_form.circle) }}
{% if edit_form.center is defined %}
{{ form_row(edit_form.center) }}
{% endif %}
{{ form_row(edit_form.label) }}
{{ form_row(edit_form.date) }}
{{ form_row(edit_form.type, { 'label': 'Event type' }) }}
<ul class="record_actions">
<li>
<a href="{{ path('chill_event_list_most_recent') }}">
Back to the list
<a href="{{ path('chill_event_list_most_recent') }}" class="sc-button bt-cancel">
{{ 'Back to the most recent events'|trans }}
</a>
</li>
<li>{{ form(delete_form) }}</li>
<li>
{{ form_widget(edit_form.submit, { 'attr' : { 'class' : 'sc-button bt-update' } }) }}
</li>
</ul>
{{ form_end(edit_form) }}
{% endblock %}

View File

@ -1,15 +1,28 @@
{% extends 'ChillEventBundle::layout.html.twig' %}
{% block event_content -%}
<h1>Event creation</h1>
{% block title 'Event creation'|trans %}
{{ form(form) }}
{% block event_content -%}
<h1>{{ 'Event creation'|trans }}</h1>
{{ form_start(form) }}
{{ form_errors(form) }}
{{ form_row(form.circle) }}
{{ form_row(form.center) }}
{{ form_row(form.label) }}
{{ form_row(form.date) }}
{{ form_row(form.type, { 'label': 'Event type' }) }}
<ul class="record_actions">
<li>
<a href="{{ path('chill_event_list_most_recent') }}">
Back to the list
<a href="{{ path('chill_event_list_most_recent') }}" class="sc-button bt-cancel">
{{ 'Back to the most recent events'|trans }}
</a>
</li>
<li>
{{ form_widget(form.submit, { 'attr' : { 'class' : 'sc-button bt-create' } }) }}
</li>
</ul>
{{ form_end(form) }}
{% endblock %}

View File

@ -30,7 +30,7 @@
<ul class="record_actions">
<li>
<a href="{{ path('chill_event__event_edit', { 'id': event.id }) }}" class="sc-button btn-edit">
<a href="{{ path('chill_event__event_edit', { 'event_id': event.id }) }}" class="sc-button btn-edit">
{{ 'Edit'|trans }}
</a>
</li>