feat: adopt sveltekit-superforms (resolves #8)
This commit is contained in:
@@ -1,26 +1,33 @@
|
||||
<script lang="ts">
|
||||
import { Button, Input, Label, Textarea } from 'flowbite-svelte';
|
||||
import RichText from '../RichText.svelte';
|
||||
interface Akti {
|
||||
title: string;
|
||||
summary: string;
|
||||
body: string;
|
||||
}
|
||||
let { akti }: { akti: Akti } = $props();
|
||||
import { superForm } from 'sveltekit-superforms';
|
||||
|
||||
let { data } = $props();
|
||||
const { form, errors, enhance } = superForm(data);
|
||||
</script>
|
||||
|
||||
<form method="POST" class="flex flex-col gap-5">
|
||||
<form method="POST" use:enhance class="flex flex-col gap-5">
|
||||
<div>
|
||||
<Label>Titu</Label>
|
||||
<Input value={akti.title} type="text" name="title" required minlength={5} />
|
||||
<Input bind:value={$form.title} type="text" name="title" required minlength={5} />
|
||||
{#if $errors.title}<span class="text-sm text-red-500">{$errors.title}</span>{/if}
|
||||
</div>
|
||||
<div>
|
||||
<Label>Zämefassig</Label>
|
||||
<Textarea value={akti.summary} name="summary" required minlength={5} class="w-full min-h-40" />
|
||||
<Textarea
|
||||
bind:value={$form.summary}
|
||||
name="summary"
|
||||
required
|
||||
minlength={5}
|
||||
class="w-full min-h-40"
|
||||
/>
|
||||
{#if $errors.summary}<span class="text-sm text-red-500">{$errors.summary}</span>{/if}
|
||||
</div>
|
||||
<div>
|
||||
<Label>Inhaut</Label>
|
||||
<RichText value={akti.body} name="body" required />
|
||||
<RichText bind:value={$form.body} name="body" required />
|
||||
{#if $errors.body}<span class="text-sm text-red-500">{$errors.body}</span>{/if}
|
||||
</div>
|
||||
<Button type="submit" class="grow-0 self-end">Spichere</Button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user