Skip to content

Form Submit with fields.set only runs if hidden fields are added. #15154

@matteopiatti

Description

@matteopiatti

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions