Forráskód Böngészése

Merge pull request #1918 from markwilson/master

Fix %name% substitution in flash_create_error message
Thomas 11 éve
szülő
commit
3932d05e77

+ 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');