Form Submit with fields.set only runs if hidden fields are added.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
When setting fields according to data (i.e. for an edit form), the form will not submit without hidden fields. Not sure if this is intentional. But I imagine it would be nice, to set fields including hidden files via fields.set as to not need to add hidden fields anymore. The form does not submit without all fields as inputs though.
<script lang="ts">
import { updatePage, getPages } from '$lib/db/remotes/page.remote';
const pages = $derived(await getPages());
updatePage.fields.set({
pageId: '6964aeb9dbcf6670463f4e4d',
title: 'test',
slug: 'slugtest',
parentId: undefined
});
</script>
<form {...updatePage}>
<label>
Title
<input {...updatePage.fields.title.as('text')} />
</label>
<label>
Slug
<input {...updatePage.fields.slug.as('text')} />
</label>
<label>
Parent Page id
<select {...updatePage.fields.parentId.as('select')}>
{#each pages as page}
<option value={page.id} selected={page.id == updatePage.fields.parentId.value()}>
{page.title}
</option>
{/each}
</select>
</label>
<button type="submit">Save</button>
</form>
Reproduction
Setup remote form with valibot. Create form in +page.svelte without one of the necessary fields as seen in the code above.
Logs
System Info
not relevant
Severity
annoyance
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the remote form setup and the reproduction in +page.svelte, then trace the fields.set submission path. Confirm the behavior with the shown fields and missing hidden fields; done means the form submits when fields are set without requiring hidden inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100