mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 17:24:16 +02:00
forms: fix isSubmitted
Implementation made wrong assumptions. A form is submitted when the submit button has been pressed. It's value is then filled, it also is when you're just pressing "RETURN". RETURN triggers the FIRST submit button in a form. This way we are also able to find out which form button has been pressed. Current implementation is still poor, however isSubmitted works as expected right now - and so does autosubmission. fixes #5967
This commit is contained in:
parent
01631720cc
commit
916c9c027e
@ -393,7 +393,13 @@ class Form extends Zend_Form
|
|||||||
foreach ($triggerElements as $elementName) {
|
foreach ($triggerElements as $elementName) {
|
||||||
$element = $this->getElement($elementName);
|
$element = $this->getElement($elementName);
|
||||||
if ($element !== null) {
|
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 {
|
} else {
|
||||||
throw new ProgrammingError(
|
throw new ProgrammingError(
|
||||||
'You need to add the element "' . $elementName . '" to' .
|
'You need to add the element "' . $elementName . '" to' .
|
||||||
@ -443,13 +449,18 @@ class Form extends Zend_Form
|
|||||||
*/
|
*/
|
||||||
public function isSubmitted()
|
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) {
|
if ($this->submitLabel) {
|
||||||
$checkData = $this->getRequest()->getParams();
|
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,6 +110,7 @@
|
|||||||
|
|
||||||
// We support an 'autosubmit' class on dropdown form elements
|
// We support an 'autosubmit' class on dropdown form elements
|
||||||
$(document).on('change', 'form select.autosubmit', { self: this }, this.autoSubmitForm);
|
$(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);
|
$(document).on('keyup', '#menu input.search', {self: this}, this.autoSubmitSearch);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user