From 4593c78d1679b03dc23aed410b5caa75166023c3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 26 Oct 2015 12:30:50 +0100 Subject: [PATCH] lib: Fix JSON response exception on form failure --- library/Icinga/Web/Form.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index ca087bfcf2..c747a0908f 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1171,10 +1171,9 @@ public function handleRequest(Request $request = null) $this->getView()->layout()->redirectUrl = $this->getRedirectUrl()->getAbsoluteUrl(); } } elseif ($this->getIsApiTarget()) { - $this->getResponse()->sendJson(array( - 'status' => 'fail', - 'data' => array_merge($this->getMessages(), $this->getErrorMessages()) - )); + $this->getResponse()->json()->setFailData( + array_merge($this->getMessages(), $this->getErrorMessages()) + )->sendResponse(); } } elseif ($this->getValidatePartial()) { // The form can't be processed but we may want to show validation errors though