From 235e75d054826d9dcac8db4240e031c167ea23f7 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 14 Feb 2017 11:15:11 +0100 Subject: [PATCH] Form: handle API requests as expected refs #2749 --- library/Icinga/Web/Form.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 9d0d5d707..c0881d997 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1143,7 +1143,7 @@ class Form extends Zend_Form } $formData = $this->getRequestData(); - if ($this->getIsApiTarget() || $this->getUidDisabled() || $this->wasSent($formData)) { + if ($this->getIsApiTarget() || $this->getRequest()->isApiRequest() || $this->getUidDisabled() || $this->wasSent($formData)) { if (($frameUpload = (bool) $request->getUrl()->shift('_frameUpload', false))) { $this->getView()->layout()->setLayout('wrapped'); } @@ -1172,7 +1172,7 @@ class Form extends Zend_Form } else { $this->getView()->layout()->redirectUrl = $this->getRedirectUrl()->getAbsoluteUrl(); } - } elseif ($this->getIsApiTarget()) { + } elseif ($this->getIsApiTarget() || $this->getRequest()->isApiRequest()) { $this->getResponse()->json()->setFailData($this->getMessages())->sendResponse(); } } elseif ($this->getValidatePartial()) { @@ -1198,7 +1198,7 @@ class Form extends Zend_Form if (strtolower($this->getRequest()->getMethod()) !== $this->getMethod()) { return false; } - if ($this->getIsApiTarget()) { + if ($this->getIsApiTarget() || $this->getRequest()->isApiRequest()) { return true; } if ($this->getSubmitLabel()) {