FormProps
Props of Form.
Props of Form. Other attributes pass to the <form> element.
Import#
ts
import type { FormProps } from "@shadow-js/dusk/client";
Signature#
ts
interface FormProps {
/** A URL (a GET to it navigates; a POST goes to it as a plain request) or a server function (a POST to its endpoint). */
readonly action?: string | FormTarget;
/** `"get"` or `"post"`. Default: `"post"` for a server function, `"get"` for a URL. */
readonly method?: "get" | "post";
/** Replace the history entry of a GET navigation. Default `false`. */
readonly replace?: boolean;
/** Do not intercept the submit: the browser submits the form itself. Default `false`. */
readonly reloadDocument?: boolean;
/** `false` leaves a GET to the browser (no client navigation). Default `true`. */
readonly navigate?: boolean;
/** After a GET navigation: `"reset"` (the router scrolls to the top, the default) or `"keep"` the scroll position. */
readonly scroll?: "reset" | "keep";
/** After a successful server function call, refresh the loader data of the page. Default `true`. */
readonly revalidate?: boolean;
/** Reset the fields after a success (not after a failure). Default `false`. */
readonly resetOnSuccess?: boolean;
/** Move focus to the first field with a problem (or to `[data-dusk-form-errors]`) after a failure. Default `true`. */
readonly focusOnError?: boolean;
/** Called with the result of a successful call (a `fail()` result included), before the form is reset. */
readonly onResult?: (result: unknown, form: HTMLFormElement) => void;
/** Called with the error of a failed call. */
readonly onError?: (error: unknown, form: HTMLFormElement) => void;
/** Called before the submit is intercepted; `preventDefault()` leaves the submit to the browser. */
readonly onSubmit?: (event: Event) => void;
readonly children?: unknown;
readonly [attribute: string]: unknown;
}
Members#
| Name | Type | Description |
|---|---|---|
action? |
readonly action?: string | FormTarget |
A URL (a GET to it navigates; a POST goes to it as a plain request) or a server function (a POST to its endpoint). |
method? |
readonly method?: "get" | "post" |
"get" or "post". Default: "post" for a server function, "get" for a URL. |
replace? |
readonly replace?: boolean |
Replace the history entry of a GET navigation. Default false. |
reloadDocument? |
readonly reloadDocument?: boolean |
Do not intercept the submit: the browser submits the form itself. Default false. |
navigate? |
readonly navigate?: boolean |
false leaves a GET to the browser (no client navigation). Default true. |
scroll? |
readonly scroll?: "reset" | "keep" |
After a GET navigation: "reset" (the router scrolls to the top, the default) or "keep" the scroll position. |
revalidate? |
readonly revalidate?: boolean |
After a successful server function call, refresh the loader data of the page. Default true. |
resetOnSuccess? |
readonly resetOnSuccess?: boolean |
Reset the fields after a success (not after a failure). Default false. |
focusOnError? |
readonly focusOnError?: boolean |
Move focus to the first field with a problem (or to [data-dusk-form-errors]) after a failure. Default true. |
onResult? |
readonly onResult?: (result: unknown, form: HTMLFormElement) => void |
Called with the result of a successful call (a fail() result included), before the form is reset. |
onError? |
readonly onError?: (error: unknown, form: HTMLFormElement) => void |
Called with the error of a failed call. |
onSubmit? |
readonly onSubmit?: (event: Event) => void |
Called before the submit is intercepted; preventDefault() leaves the submit to the browser. |
children? |
readonly children?: unknown |