Form
Form
creates a form with method
set to POST
and a couple of enhancements.
-->
Form
creates a form with method
set to POST
and a couple of enhancements.
Most of the forms we build use POST
(over GET
), so we made it a default to save a couple of keystrokes every time.
Form
contains a hidden
input to make it a tiny bit easier to prevent spam. To disable this feature, just set the preventSpam
option to false
.
If you provide Form
with a onSubmit
handler, Form
will use JavaScript to parse and sanitize data for you — without you having to lift a finger.
{
name: ""
}
Form
contains a helper that lets you send an array of objects through your forms. This is useful when you need to send multiple items of the same type.
{
}
Form
creates a <form>
element that does the following:
method
to POST
Method and other <form>
attributes can be directly added to the Form
.
If you don’t want to use the spam prevention feature, set preventSpam
to false
.
Form
will submit the form via the standard HTML way if onSubmit
is not present.
You can intercept a form submission by providing a onSubmit
callback. When you do this, Form
will:
onSubmit
callback{
name: ""
}
For Astro users: You can’t pass an onSubmit
function into Form
from an .astro
file. This is an Astro limitation.
If you want to benefit from the parsing enhancements we added here, consider using a Svelte component to handle the form submission or, use the parseData
server helper.
You can disable the sanitization of form data by setting the sanitize
option to false
.
{
name: ""
}
Form
includes a helper to send an array of objects. To activate this, make sure you have onSubmit
. Then, use the following syntax for naming your inputs:
Here’s an example of this at work:
{
}
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
Form
creates a <form>
element that does the following:
method
to POST
Method and other <form>
attributes can be directly added to the Form
.
If you don’t want to use the spam prevention feature, set preventSpam
to false
.
Form
will submit the form via the standard HTML way if onSubmit
is not present.
You can intercept a form submission by providing a onSubmit
callback. When you do this, Form
will:
onSubmit
callback{
name: ""
}
For Astro users: You can’t pass an onSubmit
function into Form
from an .astro
file. This is an Astro limitation.
If you want to benefit from the parsing enhancements we added here, consider using a Svelte component to handle the form submission or, use the parseData
server helper.
You can disable the sanitization of form data by setting the sanitize
option to false
.
{
name: ""
}
Form
includes a helper to send an array of objects. To activate this, make sure you have onSubmit
. Then, use the following syntax for naming your inputs:
Here’s an example of this at work:
{
}
Form
produces the following HTML:
The following properties can be used to add classes to Form
.
Property | Description |
---|---|
class | Class for the <form> |
styles | Inline styles for the <form> |
All other custom properties will be passed directly to <form>
.
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
Form
produces the following HTML:
The following properties can be used to add classes to Form
.
Property | Description |
---|---|
class | Class for the <form> |
styles | Inline styles for the <form> |
All other custom properties will be passed directly to <form>
.
Name | Description |
---|---|
Default | HTML to insert into the <form> . |
Property | Type | Description |
---|---|---|
method | string | HTTP method for form submission |
action | string | URL to submit the form data |
onSubmit | function | Callback function triggered on form submission |
options | object | Form configuration. See Options |
Configuration object for Form
component.
Property | Type | Default | Description |
---|---|---|---|
sanitize | boolean | true | Sanitize form inputs before passing to onSubmit . |
preventSpam | boolean | true | Include a hidden input with name="spam" for spam prevention. |
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
Name | Description |
---|---|
Default | HTML to insert into the <form> . |
Property | Type | Description |
---|---|---|
method | string | HTTP method for form submission |
action | string | URL to submit the form data |
onSubmit | function | Callback function triggered on form submission |
options | object | Form configuration. See Options |
Configuration object for Form
component.
Property | Type | Default | Description |
---|---|---|---|
sanitize | boolean | true | Sanitize form inputs before passing to onSubmit . |
preventSpam | boolean | true | Include a hidden input with name="spam" for spam prevention. |