Commit 2f7a8f1e authored by Julien Fastré's avatar Julien Fastré

add more generic message when invalid form during person update

parent 081f4f9b
......@@ -31,6 +31,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Role\Role;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\PersonBundle\Search\SimilarPersonMatcher;
use Symfony\Component\Translation\TranslatorInterface;
class PersonController extends Controller
{
......@@ -39,10 +40,19 @@ class PersonController extends Controller
* @var SimilarPersonMatcher
*/
protected $similarPersonMatcher;
/**
*
* @var TranslatorInterface
*/
protected $translator;
public function __construct(SimilarPersonMatcher $similarPersonMatcher)
{
public function __construct(
SimilarPersonMatcher $similarPersonMatcher,
TranslatorInterface $translator
) {
$this->similarPersonMatcher = $similarPersonMatcher;
$this->translator = $translator;
}
public function getCFGroup()
......@@ -119,8 +129,8 @@ class PersonController extends Controller
if ( ! $form->isValid() ) {
$this->get('session')
->getFlashBag()->add('error', 'The person data provided'
. ' are not valid');
->getFlashBag()->add('error', $this->translator
->trans('This form contains errors'));
return $this->render('ChillPersonBundle:Person:edit.html.twig',
array('person' => $person,
......
......@@ -2,4 +2,5 @@ services:
Chill\PersonBundle\Controller\PersonController:
arguments:
$similarPersonMatcher: '@Chill\PersonBundle\Search\SimilarPersonMatcher'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
tags: ['controller.service_arguments']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment