diff --git a/Controller/CRUDController.php b/Controller/CRUDController.php index 241b0b290b..25d6760cef 100644 --- a/Controller/CRUDController.php +++ b/Controller/CRUDController.php @@ -529,7 +529,7 @@ public function createAction() // show an error message if the form failed validation if (!$isFormValid) { if (!$this->isXmlHttpRequest()) { - $this->addFlash('sonata_flash_error', 'flash_create_error'); + $this->addFlash('sonata_flash_error', $this->admin->trans('flash_create_error', array('%name%' => $this->admin->toString($object)), 'SonataAdminBundle')); } } elseif ($this->isPreviewRequested()) { // pick the preview template if the form was valid and preview was requested diff --git a/Tests/Controller/CRUDControllerTest.php b/Tests/Controller/CRUDControllerTest.php index 4cfcc3dc4e..8584e47044 100644 --- a/Tests/Controller/CRUDControllerTest.php +++ b/Tests/Controller/CRUDControllerTest.php @@ -1309,6 +1309,8 @@ public function testCreateActionError() ->method('isValid') ->will($this->returnValue(false)); + $this->expectTranslate('flash_create_error'); + $this->request->setMethod('POST'); $formView = $this->getMock('Symfony\Component\Form\FormView');