mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-15 16:58:42 +00:00
handle checkboxes and fix bug
This commit is contained in:
parent
8f49a37a70
commit
a9404130b3
|
|
@ -294,15 +294,16 @@ export class FormView {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const selects = form.getElementsByTagName('select'),
|
const selects = form.getElementsByTagName('select'),
|
||||||
textareas = form.getElementsByTagName('textarea'),
|
textareas = form.getElementsByTagName('textarea'),
|
||||||
inputs = [].slice.call(form.getElementsByTagName('input')),
|
inputs = [].slice.call(form.getElementsByTagName('input')),
|
||||||
buttons = form.getElementsByTagName('button'),
|
buttons = form.getElementsByTagName('button'),
|
||||||
canvas = form.getElementsByTagName('canvas'),
|
canvas = form.getElementsByTagName('canvas'),
|
||||||
external = document.querySelectorAll('form:not(#' + this.id + ') [form=' + this.id + ']'),
|
external = [].slice.call(document.querySelectorAll(':not(#' + this.id + ') [form=' + this.id + ']')),
|
||||||
special = form.querySelectorAll('[data-name]'),
|
special = form.querySelectorAll('[data-name]'),
|
||||||
specialExt = document.querySelectorAll('form:not(#' + this.id + ') [data-form=' + this.id + '] [data-name]'),
|
specialExt = document.querySelectorAll('form:not(#' + this.id + ') [data-form=' + this.id + '] [data-name]'),
|
||||||
inputLength = inputs.length;
|
inputLength = inputs.length,
|
||||||
|
externalLength = external.length;
|
||||||
|
|
||||||
// todo: handle trigger element. check which element triggered the submit and pass it's name+value
|
// todo: handle trigger element. check which element triggered the submit and pass it's name+value
|
||||||
// the reason for this is, there may be multiple buttons in a form which trigger a send
|
// the reason for this is, there may be multiple buttons in a form which trigger a send
|
||||||
|
|
@ -310,11 +311,15 @@ export class FormView {
|
||||||
// Maybe it makes sense to do this however at a different place e.g. the actual data submit
|
// Maybe it makes sense to do this however at a different place e.g. the actual data submit
|
||||||
|
|
||||||
for (let i = 0; i < inputLength; ++i) {
|
for (let i = 0; i < inputLength; ++i) {
|
||||||
if (inputs[i].type === 'checkbox' && !inputs[i].checked) {
|
if ((inputs[i].type === 'checkbox' || inputs[i].type === 'radio') && !inputs[i].checked) {
|
||||||
delete inputs[i];
|
delete inputs[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// todo: handle radio here as well
|
for (let i = 0; i < externalLength; ++i) {
|
||||||
|
if ((external[i].type === 'checkbox' || external[i].type === 'radio') && !external[i].checked) {
|
||||||
|
delete external[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Array.prototype.slice.call(inputs).concat(
|
return Array.prototype.slice.call(inputs).concat(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user