perf: Migliorata funzionalità di retrieve dei dati di un form

This commit is contained in:
Maicol Battistini 2022-02-14 18:24:07 +01:00
parent 68f949922a
commit d266614695
No known key found for this signature in database
GPG Key ID: 4FDB0F87CDB1D34A
1 changed files with 6 additions and 1 deletions

View File

@ -83,7 +83,12 @@ export async function showSnackbar(
});
}
export function getFormData(form: Cash) {
return Object.fromEntries<string | File>(new FormData(form[0] as HTMLFormElement));
const data: Record<string, any> = {};
const inputs = form.find('text-field, material-select, text-area');
inputs.each((index, input) => {
data[input.id] = (input as HTMLInputElement).value;
});
return data;
}
export function isFormValid(element: Cash | HTMLFormElement): boolean {
let form = element;