kit icon indicating copy to clipboard operation
kit copied to clipboard

Missing field for form doesn't report error

Open LumiFae opened this issue 1 month ago • 3 comments

Describe the bug

Currently when you create a remote form, you must use the {...form.fields.field.as(...)} syntax when making a form field, but if you forget to add this for one of the required fields, nothing will happen at all. No errors will get thrown, no warnings indicating something is wrong, just nothing will happen on the form submit.

(Also I find it weird that the syntax now required, whereas before it worked fine using the standard name="name" value="value" type="text", but that's not the point of this)

Reproduction

Here is what I managed to make on stack blitz

https://stackblitz.com/edit/sveltejs-kit-template-default-cb8vsuzs?file=src%2Froutes%2F%2Bpage.svelte

Just add the other form field and remove it, and see that nothing happens.

Logs


System Info

OS: macOS 26.0.1
CPU: arm64 Apple M3 Pro
Memory: 97.94 MB / 18.00 GB
Shell: 5.9 - /bin/zsh

Node: 20.19.4
npm: 10.8.2
bun: 1.3.2

Browser: Zen 1.16.4b (Firefox 143.0.4)

Severity

serious, but I can work around it

Additional Information

This is just quite annoying, spent a load of time debugging loads of my forms because of this, also dynamic forms (Record<string, boolean> for example) are also having issues because of this, still trying to see if I can fix that though.

LumiFae avatar Nov 26 '25 09:11 LumiFae

Sometimes an absent input is allowed, because it's optional and is conditionally rendered ({#if}). When developing and testing I have a component to display all the form issues and disable it on build. It could be just as simple as:

{#if dev}
    <pre>{JSON.stringify(remoteForm.fields.allIssues(), null, 2)}</pre>
{/if}

henrykrinkle01 avatar Nov 26 '25 10:11 henrykrinkle01

Clever idea, and that does actually help me get all the issues and be able to solve them. Just would be good if there was a better way to actually get the errors without doing this.

LumiFae avatar Nov 26 '25 11:11 LumiFae

I just wasted an hour on this as well. Silent errors are the worst...

(..and just like the OP, i too was surprised that just using name="..." would not work given Svelte's philosophy of embracing standard html etc. I thought the .as(..) was sugar/helper, not a requirement)

einarpersson avatar Dec 05 '25 14:12 einarpersson