Fix #2043: use formvalue instead of String for forms (#2103)

Fix #2043: use formvalue instead of String for forms
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-03-18 18:21:08 -07:00
1 parent 468d2b6b3b
commit 2dc6cecf2e
11 files changed
+100 -37

No files matched your search

+4 -4
View File
@@ -2,7 +2,7 @@
type FormValues = {
valid?: boolean;
values: { [key: string]: FormDataEntryValue };
values: { [key: string]: FormDataEntryValue[] };
}
export function retriveValues(event: Event, target: HTMLElement): FormValues {
@@ -33,12 +33,12 @@ export function retriveValues(event: Event, target: HTMLElement): FormValues {
// We encode select multiple as a comma separated list which breaks... when there's commas in the values
export function retrieveFormValues(form: HTMLFormElement): FormValues {
const formData = new FormData(form);
const contents: { [key: string]: FormDataEntryValue } = {};
const contents: { [key: string]: FormDataEntryValue[] } = {};
formData.forEach((value, key) => {
if (contents[key]) {
contents[key] += "," + value;
contents[key].push(value);
} else {
contents[key] = value;
contents[key] = [value];
}
});
return {
+1 -1
View File
@@ -5,7 +5,7 @@ import { retriveSelectValue, retriveValues } from "./form";
export type AppTouchEvent = TouchEvent;
export type SerializedEvent = {
values?: { [key: string]: FormDataEntryValue };
values?: { [key: string]: FormDataEntryValue[] };
value?: string;
[key: string]: any;
};