From d01194a7b42cfc7bf78a024b98fd73466a8795cb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 24 May 2016 20:25:16 +0200 Subject: [PATCH] QuickForm: optimize runtime order --- library/Director/Web/Form/QuickForm.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/library/Director/Web/Form/QuickForm.php b/library/Director/Web/Form/QuickForm.php index 75773f5d..0aa9ad54 100644 --- a/library/Director/Web/Form/QuickForm.php +++ b/library/Director/Web/Form/QuickForm.php @@ -84,7 +84,9 @@ abstract class QuickForm extends QuickBaseForm protected function addSubmitButtonIfSet() { if (false !== ($label = $this->getSubmitLabel())) { - $el = $this->createElement('submit', $label)->setLabel($label)->setDecorators(array('ViewHelper')); + $el = $this->createElement('submit', $label) + ->setLabel($label) + ->setDecorators(array('ViewHelper')); $this->submitButtonName = $el->getName(); $this->addElement($el); @@ -296,12 +298,16 @@ abstract class QuickForm extends QuickBaseForm public function handleRequest(Request $request = null) { - if ($request !== null) { + if ($request === null) { + $request = $this->getRequest(); + } else { $this->setRequest($request); } + $this->prepareElements(); + if ($this->hasBeenSent()) { - $post = $this->getRequest()->getPost(); + $post = $request->getPost(); if ($this->hasBeenSubmitted()) { $this->beforeValidation($post); if ($this->isValid($post)) { @@ -416,7 +422,13 @@ abstract class QuickForm extends QuickBaseForm public function hasBeenSent() { if ($this->hasBeenSent === null) { - $req = $this->getRequest(); + + if ($this->request === null) { + $req = Icinga::app()->getFrontController()->getRequest(); + } else { + $req = $this->request; + } + if ($req->isPost()) { $post = $req->getPost(); $this->hasBeenSent = array_key_exists(self::ID, $post) &&