From 46173231d2d9c66ebad345e039984739d6dbac74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 27 Nov 2015 14:18:19 +0100 Subject: [PATCH] adding flash messages for customfield --- Controller/CustomFieldController.php | 17 +++++++++++++++-- Resources/translations/messages.fr.yml | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Controller/CustomFieldController.php b/Controller/CustomFieldController.php index 204652612..8342ea765 100644 --- a/Controller/CustomFieldController.php +++ b/Controller/CustomFieldController.php @@ -27,9 +27,16 @@ class CustomFieldController extends Controller $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); + + $this->addFlash('success', $this->get('translator') + ->trans('The custom field has been created')); - return $this->redirect($this->generateUrl('customfield_show', array('id' => $entity->getId()))); - } + return $this->redirect($this->generateUrl('customfieldsgroup_show', + array('id' => $entity->getCustomFieldsGroup()->getId()))); + } + + $this->addFlash('error', $this->get('translator') + ->trans("The custom field form contains errors")); return $this->render('ChillCustomFieldsBundle:CustomField:new.html.twig', array( 'entity' => $entity, @@ -166,9 +173,15 @@ class CustomFieldController extends Controller if ($editForm->isValid()) { $em->flush(); + + $this->addFlash('success', $this->get('translator') + ->trans("The custom field has been updated")); return $this->redirect($this->generateUrl('customfield_edit', array('id' => $id))); } + + $this->addFlash('error', $this->get('translator') + ->trans("The custom field form contains errors")); return $this->render('ChillCustomFieldsBundle:CustomField:edit.html.twig', array( 'entity' => $entity, diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 469f4f2a9..38e037506 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -37,6 +37,9 @@ Custom fields group: Groupe de champ personnalisé Ordering: Ordre d'apparition Back to the group: Retour au groupe de champs personnalisé Slug: Identifiant textuel +The custom field has been created: Le champ personnalisé est créé +The custom field form contains errors: Le formulaire contient des erreurs +The custom field has been updated: Le champ personnalisé a été mis à jour #custom field name choice: choix