kit
kit copied to clipboard
`enhance` submit function `formData` re-assignable does nothing / no type error
Describe the bug
Via enhance, additional form data can be added, but reassigning the formData as a whole does nothing, nor does it cause a type error.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-vylhwt?file=src%2Froutes%2F%2Bpage.svelte
Relevant example:
<script>
import { enhance } from '$app/forms';
function createData() {
const data = new FormData();
data.append('greeting', 'Hello World');
return data;
}
</script>
<form method="post" use:enhance={e => {
e.formData = createData();
// this would work:
// for (const [key, value] of createData())
// e.formData.append(key, value);
}} >
<button>Submit</button>
</form>
Logs
No response
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.4.2 - /usr/local/bin/npm
pnpm: 8.10.5 - /usr/local/bin/pnpm
npmPackages:
@sveltejs/adapter-auto: ^2.0.0 => 2.1.1
@sveltejs/kit: ^1.27.4 => 1.27.6
svelte: ^4.2.7 => 4.2.7
vite: ^4.4.2 => 4.5.0
Severity
annoyance
Additional Information
No response
WHY IS THERE NO RESPONSE TO THIS!? I'M CURRENTLY DEALING WITH THIS ISSUE AS WELL-
The workaround is simple: Modify the existing formData.