Explorar el Código

Merge pull request #1 from markwilson/hotfix/flash-create-error-translation

Hotfix/flash create error translation
Mark Wilson hace 11 años
padre
commit
4a47b36876
Se han modificado 2 ficheros con 3 adiciones y 1 borrados
  1. 1 1
      Controller/CRUDController.php
  2. 2 0
      Tests/Controller/CRUDControllerTest.php

+ 1 - 1
Controller/CRUDController.php

@@ -529,7 +529,7 @@ class CRUDController extends Controller
             // 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

+ 2 - 0
Tests/Controller/CRUDControllerTest.php

@@ -1309,6 +1309,8 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
             ->method('isValid')
             ->will($this->returnValue(false));
 
+        $this->expectTranslate('flash_create_error');
+
         $this->request->setMethod('POST');
 
         $formView = $this->getMock('Symfony\Component\Form\FormView');