Skip to content

Commit

Permalink
Merge pull request #1 from markwilson/hotfix/flash-create-error-trans…
Browse files Browse the repository at this point in the history
…lation

Hotfix/flash create error translation
  • Loading branch information
markwilson committed Jan 23, 2014
2 parents a4e22f8 + 1bfb720 commit 4a47b36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Tests/Controller/CRUDControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 4a47b36

Please sign in to comment.