add more generic message when invalid form during person update

This commit is contained in:
Julien Fastré 2018-08-20 21:34:53 +02:00
parent 081f4f9b4c
commit 2f7a8f1ebc
2 changed files with 15 additions and 4 deletions

View File

@ -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,

View File

@ -2,4 +2,5 @@ services:
Chill\PersonBundle\Controller\PersonController:
arguments:
$similarPersonMatcher: '@Chill\PersonBundle\Search\SimilarPersonMatcher'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
tags: ['controller.service_arguments']