diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index b2361701f..1e9ab786e 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -8,6 +8,7 @@ use Zend_Form; use Zend_View_Interface; use Icinga\Application\Icinga; use Icinga\Web\Form\Decorator\HelpText; +use Icinga\Web\Form\Decorator\NoScriptApply; use Icinga\Web\Form\Decorator\ElementWrapper; use Icinga\Web\Form\Element\CsrfCounterMeasure; @@ -330,6 +331,14 @@ class Form extends Zend_Form $el->removeDecorator('HtmlTag'); $el->removeDecorator('Label'); $el->removeDecorator('DtDdWrapper'); + + if ($el->getAttrib('autosubmit')) { + // Need to add this decorator first or it interferes with the other's two HTML otherwise + $el->addDecorator(new NoScriptApply()); // Non-JS environments + $el->setAttrib('class', 'autosubmit'); // JS environments + unset($el->autosubmit); + } + $el->addDecorator(new ElementWrapper()); $el->addDecorator(new HelpText()); } diff --git a/library/Icinga/Web/Form/Decorator/NoScriptApply.php b/library/Icinga/Web/Form/Decorator/NoScriptApply.php new file mode 100644 index 000000000..509c3531e --- /dev/null +++ b/library/Icinga/Web/Form/Decorator/NoScriptApply.php @@ -0,0 +1,35 @@ +'; + } + + return $content; + } +}