From 62aacce4692852ff037892bc2123b69c2d43fda9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 12 Nov 2014 10:48:52 +0100 Subject: [PATCH] Place the noscript button next to the element it is supposed to apply --- library/Icinga/Web/Form.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index b0f0df4dc..f315c264e 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -463,7 +463,15 @@ class Form extends Zend_Form $el = parent::createElement($type, $name, $options); if ($el && $el->getAttrib('autosubmit')) { - $el->addDecorator(new NoScriptApply()); // Non-JS environments + $noScript = new NoScriptApply(); // Non-JS environments + $decorators = $el->getDecorators(); + $pos = array_search('Zend_Form_Decorator_ViewHelper', array_keys($decorators)) + 1; + $el->setDecorators( + array_slice($decorators, 0, $pos, true) + + array(get_class($noScript) => $noScript) + + array_slice($decorators, $pos, count($decorators) - $pos, true) + ); + $class = $el->getAttrib('class'); if (is_array($class)) { $class[] = 'autosubmit'; @@ -473,6 +481,7 @@ class Form extends Zend_Form $class .= ' autosubmit'; } $el->setAttrib('class', $class); // JS environments + unset($el->autosubmit); }