diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 02c9787f4..328de50de 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -393,7 +393,13 @@ class Form extends Zend_Form foreach ($triggerElements as $elementName) { $element = $this->getElement($elementName); if ($element !== null) { - $element->setAttrib('onchange', '$(this.form).submit();'); + $class = $element->getAttrib('class'); + if ($class === null) { + $class = 'autosubmit'; + } else { + $class .= ' autosubmit'; + } + $element->setAttrib('class', $class); } else { throw new ProgrammingError( 'You need to add the element "' . $elementName . '" to' . @@ -443,13 +449,18 @@ class Form extends Zend_Form */ public function isSubmitted() { - $submitted = true; + // TODO: There are some missunderstandings and missconceptions to be + // found in this class. If populate() etc would have been used as + // designed this function would read as simple as: + // return $this->getElement('btn_submit')->isChecked(); + if ($this->submitLabel) { $checkData = $this->getRequest()->getParams(); - $submitted = isset($checkData['btn_submit']); + $label = isset($checkData['btn_submit']) ? $checkData['btn_submit'] : null; + return $label === $this->submitLabel; } - return $submitted; + return true; } /** diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 69d75ee46..18b1d4aff 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -110,6 +110,7 @@ // We support an 'autosubmit' class on dropdown form elements $(document).on('change', 'form select.autosubmit', { self: this }, this.autoSubmitForm); + $(document).on('change', 'form input.autosubmit', { self: this }, this.autoSubmitForm); $(document).on('keyup', '#menu input.search', {self: this}, this.autoSubmitSearch);