From 506e5c3de0d093300188eb4b2035d9ac1d743fb8 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 3 Apr 2017 12:07:02 +0200 Subject: [PATCH] Output _formvars when closing the renderer, instead of when opening the form. This way can output all expected form variables for all rendered sub-forms at once. Fixes bug #14604. Did I mention that Horde_Form is a mess and desperately needs refactoring? --- framework/Form/lib/Horde/Form.php | 1 - framework/Form/lib/Horde/Form/Renderer.php | 20 +++++++++++++++++++- framework/Form/package.xml | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/framework/Form/lib/Horde/Form.php b/framework/Form/lib/Horde/Form.php index 54c61aaedb0..fed2a12b9af 100644 --- a/framework/Form/lib/Horde/Form.php +++ b/framework/Form/lib/Horde/Form.php @@ -416,7 +416,6 @@ function open(&$renderer, &$vars, $action, $method = 'get', $enctype = null) $enctype = $this->_enctype; } $renderer->open($action, $method, $this->_name, $enctype); - $renderer->listFormVars($this); if (!empty($this->_name)) { $this->_preserveVarByPost('formname', $this->_name); diff --git a/framework/Form/lib/Horde/Form/Renderer.php b/framework/Form/lib/Horde/Form/Renderer.php index abc0a740f26..8790be29911 100644 --- a/framework/Form/lib/Horde/Form/Renderer.php +++ b/framework/Form/lib/Horde/Form/Renderer.php @@ -32,6 +32,7 @@ class Horde_Form_Renderer { var $_varRenderer = null; var $_firstField = null; var $_stripedRows = false; + var $_forms = array(); /** * Does the title of the form contain HTML? If so, you are responsible for @@ -195,6 +196,7 @@ function end() function close($focus = true) { + $this->_listAllFormVars(); echo "\n"; if ($focus) { $GLOBALS['injector'] @@ -206,7 +208,7 @@ function close($focus = true) } } - function listFormVars(&$form) + function getFormVars($form) { $variables = $form->getVariables(true, true); $vars = array(); @@ -237,6 +239,20 @@ function listFormVars(&$form) } } } + return $vars; + } + + function listFormVars(&$form) + { + echo ''; + } + + function _listAllFormVars() + { + $vars = array(); + foreach ($this->_forms as $form) { + $vars = array_merge($vars, $this->getFormVars($form)); + } echo ''; } @@ -252,6 +268,8 @@ function renderFormInactive(&$form, &$vars) function _renderForm(&$form, &$vars, $active) { + $this->_forms[] = $form; + /* If help is present 3 columns are needed. */ $this->_cols = $form->hasHelp() ? 3 : 2; diff --git a/framework/Form/package.xml b/framework/Form/package.xml index 3d4c25dba83..40a4854db0f 100644 --- a/framework/Form/package.xml +++ b/framework/Form/package.xml @@ -27,7 +27,7 @@ LGPL-2.1 -* +* [jan] Fix regression when submitting multiple forms (Bug #14604). @@ -1004,7 +1004,7 @@ Converted to package.xml 2.0 for pear.horde.org 2017-03-20 LGPL-2.1 -* +* [jan] Fix regression when submitting multiple forms (Bug #14604).