feat: adopt sveltekit-superforms (resolves #8)
Commit / ci (push) Successful in 10m39s
PullRequest / publish (pull_request) Failing after 2m25s

This commit is contained in:
2026-04-03 13:08:34 +02:00
parent 2e16cf9d51
commit 6ec5670267
11 changed files with 500 additions and 141 deletions
+17 -10
View File
@@ -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>