From fc481e527bc021144205e9fea88397bdf5ce60bc Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 21 Jul 2015 15:22:24 +0200 Subject: [PATCH] Form: Process request parameter _frameUpload This parameter is being used to flag a request as form submission issued by utilizing an iframe. Appending it to a form's action causes no redirection to take place in case of successful submission and a reduced but still valid layout to be printed in any way. Redirection must be handled by the client regarding the meta tag "redirectUrl". refs #8758 --- application/layouts/scripts/wrapped.phtml | 10 ++++++++++ library/Icinga/Web/Form.php | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 application/layouts/scripts/wrapped.phtml diff --git a/application/layouts/scripts/wrapped.phtml b/application/layouts/scripts/wrapped.phtml new file mode 100644 index 000000000..25a7cf2e4 --- /dev/null +++ b/application/layouts/scripts/wrapped.phtml @@ -0,0 +1,10 @@ + + + layout()->redirectUrl)): ?> + + + + + render('inline.phtml'); ?> + + \ No newline at end of file diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 816ea0469..1e5487f7c 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -946,12 +946,20 @@ class Form extends Zend_Form $formData = $this->getRequestData(); if ($this->getUidDisabled() || $this->wasSent($formData)) { + if (($frameUpload = (bool) $request->getUrl()->shift('_frameUpload', false))) { + $this->getView()->layout()->setLayout('wrapped'); + } + $this->populate($formData); // Necessary to get isSubmitted() to work if (! $this->getSubmitLabel() || $this->isSubmitted()) { if ($this->isValid($formData) && (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $this)) || ($this->onSuccess === null && false !== $this->onSuccess()))) { - $this->getResponse()->redirectAndExit($this->getRedirectUrl()); + if (! $frameUpload) { + $this->getResponse()->redirectAndExit($this->getRedirectUrl()); + } + + $this->getView()->layout()->redirectUrl = $this->getRedirectUrl(); } } elseif ($this->getValidatePartial()) { // The form can't be processed but we may want to show validation errors though