Can't get value from shadcn-svelte Input (used example from docs) #1497
Answered
by
huntabyte
CarlosGTrejo
asked this question in
Help
-
When I check the form data in my <!-- +page.svelte -->
<script lang="ts">
import { Button } from "$lib/components/ui/button/index.js";
import { Input } from "$lib/components/ui/input/index.js";
</script>
<form method="POST" class="flex w-full max-w-sm items-center space-x-2">
<Input id="name" type="test" placeholder="name" />
<Button type="submit">Next</Button>
</form> // +page.server.ts
import type { Actions } from './$types';
export const actions = {
default: async ({ request }) => {
const form = await request.formData();
console.log(form);
const name= form.get('name');
console.log(name);
}
} satisfies Actions; Output:
I'm using the next shadcn-svelte components for my Sveltekit project. |
Beta Was this translation helpful? Give feedback.
Answered by
huntabyte
Nov 17, 2024
Replies: 1 comment 1 reply
-
Give the input a |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
CarlosGTrejo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Give the input a
name
attribute :)