mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-05 04:46:03 +01:00
Always submit checkboxes that are not checked and force a 0 value (fixes #616)
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
* Show page title in Delete Confirmation modal if this information is available
|
* Show page title in Delete Confirmation modal if this information is available
|
||||||
* Don't try to uninstall admin/form/login/email plugins
|
* Don't try to uninstall admin/form/login/email plugins
|
||||||
* Only check for updates if not `admin.maintenance` or `admin.super` [#557](https://github.com/getgrav/grav-plugin-admin/issues/557)
|
* Only check for updates if not `admin.maintenance` or `admin.super` [#557](https://github.com/getgrav/grav-plugin-admin/issues/557)
|
||||||
|
* Always submit checkboxes that are not checked and force a 0 value [#616](https://github.com/getgrav/grav-plugin-admin/issues/616)
|
||||||
|
|
||||||
# v1.1.0-beta.5
|
# v1.1.0-beta.5
|
||||||
## 05/23/2016
|
## 05/23/2016
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export default class Form {
|
|||||||
this._attachShortcuts();
|
this._attachShortcuts();
|
||||||
this._attachToggleables();
|
this._attachToggleables();
|
||||||
this._attachDisabledFields();
|
this._attachDisabledFields();
|
||||||
|
this._submitUncheckedFields();
|
||||||
|
|
||||||
this.observer = new MutationObserver(this.addedNodes);
|
this.observer = new MutationObserver(this.addedNodes);
|
||||||
this.form.each((index, form) => this.observer.observe(form, { subtree: true, childList: true }));
|
this.form.each((index, form) => this.observer.observe(form, { subtree: true, childList: true }));
|
||||||
@@ -96,6 +97,22 @@ export default class Form {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_submitUncheckedFields() {
|
||||||
|
this.form.on('submit', () => {
|
||||||
|
let unchecked = this.form.find('input[type="checkbox"]:not(:checked)');
|
||||||
|
if (!unchecked.length) { return true; }
|
||||||
|
|
||||||
|
unchecked.each((index, element) => {
|
||||||
|
element = $(element);
|
||||||
|
let name = element.prop('name');
|
||||||
|
let fake = $(`<input type="hidden" name="${name}" value="0" />`);
|
||||||
|
this.form.append(fake);
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
addedNodes(mutations) {
|
addedNodes(mutations) {
|
||||||
mutations.forEach((mutation) => {
|
mutations.forEach((mutation) => {
|
||||||
if (mutation.type !== 'childList' || !mutation.addedNodes) { return; }
|
if (mutation.type !== 'childList' || !mutation.addedNodes) { return; }
|
||||||
|
|||||||
Reference in New Issue
Block a user