mirror of
https://github.com/dzeiocom/FormManager.git
synced 2025-04-23 19:32:14 +00:00
Added data-datalist to select input
Signed-off-by: Florian Bouillon <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
a2edf678e6
commit
8646cd43df
@ -129,7 +129,7 @@ export default class RepeatInput extends DefaultInput {
|
||||
|
||||
if (this.element.querySelectorAll(".fmr-element").length <= index) {
|
||||
//add element
|
||||
if ((el as any) == "") continue
|
||||
if (!el) continue
|
||||
this.addLine(el)
|
||||
continue
|
||||
}
|
||||
@ -160,6 +160,10 @@ export default class RepeatInput extends DefaultInput {
|
||||
}
|
||||
|
||||
public verify(): boolean {
|
||||
console.log(this.elements.length)
|
||||
if (this.element.hasAttribute('required') && this.elements.length === 0) {
|
||||
return false
|
||||
}
|
||||
for (const el of this.elements) {
|
||||
for (const i of el) {
|
||||
if (!i.verify()) return false
|
||||
|
@ -7,6 +7,20 @@ export default class SelectInput extends DefaultInput {
|
||||
|
||||
public constructor(element: HTMLSelectElement, form: FormManager) {
|
||||
super(element, form)
|
||||
if (element.hasAttribute('data-datalist')) {
|
||||
const datalist = document.querySelector(`#${element.dataset.datalist}`)
|
||||
if (!datalist) {
|
||||
console.warn('Error, Datalist does not exist')
|
||||
} else {
|
||||
for (const child of element.children) {
|
||||
!(child as HTMLElement).hasAttribute('disabled') && child.remove()
|
||||
}
|
||||
for (const child of datalist.children) {
|
||||
// console.log(child.value)
|
||||
element.appendChild(child.cloneNode(true))
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element.dataset.filterElement) {
|
||||
const options = element.querySelectorAll('option')
|
||||
const el = form.form.querySelector<HTMLInputElement>(`[name="${element.dataset.filterElement}"]`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user