forked from fabian-hiller/modular-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add form submit method fabian-hiller#130
- Loading branch information
Showing
11 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { FieldValues, FormStore, ResponseData } from '../types'; | ||
|
||
/** | ||
* Validates and submits the form. | ||
* | ||
* @param form The form to be validated and submitted. | ||
*/ | ||
export function submit< | ||
TFieldValues extends FieldValues, | ||
TResponseData extends ResponseData | ||
>(form: FormStore<TFieldValues, TResponseData>): void { | ||
form.element.value?.requestSubmit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { FieldValues, FormStore, ResponseData } from '../types'; | ||
|
||
/** | ||
* Validates and submits the form. | ||
* | ||
* @param form The form to be validated and submitted. | ||
*/ | ||
export function submit< | ||
TFieldValues extends FieldValues, | ||
TResponseData extends ResponseData | ||
>(form: FormStore<TFieldValues, TResponseData>): void { | ||
form.element?.requestSubmit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { FieldValues, FormStore, ResponseData } from '../types'; | ||
|
||
/** | ||
* Validates and submits the form. | ||
* | ||
* @param form The form to be validated and submitted. | ||
*/ | ||
export function submit< | ||
TFieldValues extends FieldValues, | ||
TResponseData extends ResponseData | ||
>(form: FormStore<TFieldValues, TResponseData>): void { | ||
form.element.value?.requestSubmit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { FieldValues, FormStore, ResponseData } from '../types'; | ||
|
||
/** | ||
* Validates and submits the form. | ||
* | ||
* @param form The form to be validated and submitted. | ||
*/ | ||
export function submit< | ||
TFieldValues extends FieldValues, | ||
TResponseData extends ResponseData | ||
>(form: FormStore<TFieldValues, TResponseData>): void { | ||
form.element?.requestSubmit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Description, Property, Title } from '~/components'; | ||
|
||
<Title>submit</Title> | ||
<Description>Validates and submits the specified form.</Description> | ||
|
||
# submit | ||
|
||
Validates and submits the specified form. | ||
|
||
```ts | ||
submit(form); | ||
``` | ||
|
||
## Parameters | ||
|
||
- `form` <Property {...properties.form} /> | ||
|
||
export const properties = { | ||
form: { | ||
type: { | ||
type: 'custom', | ||
name: 'FormStore', | ||
href: '../FormStore', | ||
}, | ||
}, | ||
}; |