[icinga-checkins] icinga.org: icingaweb2/feature/setup-wizard-7163: Place the noscript button next to the element it is supposed to apply

git at icinga.org git at icinga.org
Wed Nov 12 12:11:35 CET 2014


Module: icingaweb2
Branch: feature/setup-wizard-7163
Commit: 62aacce4692852ff037892bc2123b69c2d43fda9
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=62aacce4692852ff037892bc2123b69c2d43fda9

Author: Johannes Meyer <johannes.meyer at netways.de>
Date:   Wed Nov 12 10:48:52 2014 +0100

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 b0f0df4..f315c26 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);
         }
 



More information about the icinga-checkins mailing list