You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- The recommended way to build forms when using Inertia is with the `<Form>` component. Use `search-docs` with `form component` for guidance.
9
+
- Forms can also be built using the `useForm` helper for more programmatic control, or to follow existing conventions. Use `search-docs` with `useForm helper` for guidance.
10
+
11
+
@boostsnippet("Example form using the `<Form>` component", "react")
12
+
import { Form } from '@inertiajs/react'
13
+
14
+
export default () => (
15
+
<Formaction="/users"method="post">
16
+
{({
17
+
errors,
18
+
hasErrors,
19
+
processing,
20
+
progress,
21
+
wasSuccessful,
22
+
recentlySuccessful,
23
+
setError,
24
+
clearErrors,
25
+
resetAndClearErrors,
26
+
defaults,
27
+
isDirty,
28
+
reset,
29
+
submit,
30
+
}) => (
31
+
<>
32
+
<inputtype="text"name="name" />
33
+
34
+
{errors.name && <div>{errors.name}</div>}
35
+
36
+
<buttontype="submit"disabled={processing}>
37
+
{processing ? 'Creating...' : 'Create User'}
38
+
</button>
39
+
40
+
{wasSuccessful && <div>User created successfully!</div>}
41
+
</>
42
+
)}
43
+
</Form>
44
+
)
45
+
@endboostsnippet
46
+
47
+
@if($assist->inertia()->hasFormComponentResets())
48
+
- Added `resetOnError`, `resetOnSuccess`, and `setDefaultsOnSuccess` to the `<Form>` component. Use `search-docs` with 'form component resetting' for explicit guidance.
49
+
@else
50
+
- This version of Inertia does NOT support `resetOnError`, `resetOnSuccess`, or `setDefaultsOnSuccess` on the `<Form>` component.
0 commit comments