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

@ -41,6 +41,9 @@ class EventController extends Controller
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($entity); $em->persist($entity);
$em->flush(); $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()))); return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId())));
} }
@ -186,6 +189,7 @@ class EventController extends Controller
'method' => 'PUT', 'method' => 'PUT',
)); ));
$form->remove('center');
$form->add('submit', 'submit', array('label' => 'Update')); $form->add('submit', 'submit', array('label' => 'Update'));
@ -211,6 +215,9 @@ class EventController extends Controller
if ($editForm->isValid()) { if ($editForm->isValid()) {
$em->flush(); $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))); return $this->redirect($this->generateUrl('chill_event__event_edit', array('event_id' => $event_id)));
} }

View File

@ -1,5 +1,6 @@
#events #events
Name: Nom Name: Nom
Label: Nom
Date: Date Date: Date
Event type : Type d'événement Event type : Type d'événement
See: Voir See: Voir
@ -14,6 +15,12 @@ Last update: Dernière mise à jour
#CRUD event #CRUD event
Details of an event: Détails d'un événement Details of an event: Détails d'un événement
New event: Nouvel é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 #crud participation
Edit all the participations: Modifier toutes les participations Edit all the participations: Modifier toutes les participations

View File

@ -1,16 +1,30 @@
{% extends 'ChillEventBundle::layout.html.twig' %} {% extends 'ChillEventBundle::layout.html.twig' %}
{% block title 'Event edit'|trans %}
{% block event_content -%} {% block event_content -%}
<h1>Event edit</h1> <h1>{{ 'Event edit'|trans }}</h1>
{{ form(edit_form) }} {{ 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"> <ul class="record_actions">
<li> <li>
<a href="{{ path('chill_event_list_most_recent') }}"> <a href="{{ path('chill_event_list_most_recent') }}" class="sc-button bt-cancel">
Back to the list {{ 'Back to the most recent events'|trans }}
</a> </a>
</li> </li>
<li>{{ form(delete_form) }}</li> <li>
</ul> {{ form_widget(edit_form.submit, { 'attr' : { 'class' : 'sc-button bt-update' } }) }}
</li>
</ul>
{{ form_end(edit_form) }}
{% endblock %} {% endblock %}

View File

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

View File

@ -30,7 +30,7 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <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 }} {{ 'Edit'|trans }}
</a> </a>
</li> </li>