first commit

This commit is contained in:
Ariyutta
2026-08-07 10:47:09 +07:00
commit 1c094fbe7f
11630 changed files with 1580900 additions and 0 deletions
@@ -0,0 +1,33 @@
## Inertia v1 + Svelte Forms
- For form handling, use `router.post` and related methods. Do not use regular forms.
@verbatim
<code-snippet name="Inertia Svelte Form Example" lang="svelte">
<script>
import { router } from '@inertiajs/svelte'
let values = {
first_name: null,
last_name: null,
email: null,
}
function handleSubmit() {
router.post('/users', values)
}
</script>
<form on:submit|preventDefault={handleSubmit}>
<label for="first_name">First name:</label>
<input id="first_name" bind:value={values.first_name}>
<label for="last_name">Last name:</label>
<input id="last_name" bind:value={values.last_name}>
<label for="email">Email:</label>
<input id="email" bind:value={values.email}>
<button type="submit">Submit</button>
</form>
</code-snippet>
@endverbatim
@@ -0,0 +1,75 @@
@php
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
@endphp
## Inertia v2 + Svelte Forms
- There are critical differences between Svelte 4 and 5; use the `search-docs` tool for up-to-date guidance.
@if($assist->inertia()->hasFormComponent())
@boostsnippet("`<Form>` Component Example", "svelte5")
<Form action="/users" method="post">
{#snippet children({
errors,
hasErrors,
processing,
progress,
wasSuccessful,
recentlySuccessful,
setError,
clearErrors,
resetAndClearErrors,
defaults,
isDirty,
reset,
submit,
})}
<input type="text" name="name" />
{#if errors.name}
<div>{errors.name}</div>
{/if}
<button type="submit" disabled={processing}>
{processing ? 'Creating...' : 'Create User'}
</button>
{#if wasSuccessful}
<div>User created successfully!</div>
{/if}
{/snippet}
</Form>
@endboostsnippet
@endif
@if($assist->inertia()->hasFormComponent() === false)
{{-- Inertia 2.0.x, not 2.1.0 or higher. So they still need to use 'useForm' --}}
@boostsnippet("Inertia Svelte useForm Example", "svelte")
<script>
import { useForm } from '@inertiajs/svelte'
const form = useForm({
email: null,
password: null,
remember: false,
})
function submit(e) {
e.preventDefault() /* Only required with Svelte 5 */
$form.post('/login')
}
</script>
<form onsubmit={submit}>
<input type="text" bind:value={$form.email} />
{#if $form.errors.email}
<div class="form-error">{$form.errors.email}</div>
{/if}
<input type="password" bind:value={$form.password} />
{#if $form.errors.password}
<div class="form-error">{$form.errors.password}</div>
{/if}
<input type="checkbox" bind:checked={$form.remember} /> Remember Me
<button type="submit" disabled={$form.processing}>Submit</button>
</form>
@endboostsnippet
@endif
+10
View File
@@ -0,0 +1,10 @@
## Inertia + Svelte
- Use `router.visit()` or `<Link>` for navigation instead of traditional links.
@boostsnippet("Inertia Client Navigation", "svelte")
import { inertia, Link } from '@inertiajs/svelte'
<a href="/" use:inertia>Home</a>
<Link href="/">Home</Link>
@endboostsnippet