React Advanced Form
Getting started
Validation
GitHub
Search…
Introduction
General
Comparison
Migration guides
FAQ
Getting started
Installation
Creating fields
Creating form
Validation rules
Validation messages
Applying validation
Handle submit
Architecture
Argument properties
Referencing
Field lifecycle
Controlled fields
Reactive props
Validation
Getting started
Validation schema
Validation messages
High-order components
createField
Components
FormProvider
Form
Field.Group
Field
Recipes
Generating a form
Utilizing functions
Developers
Contributing
Powered By
GitBook
Handle submit
Provide the
action
prop to handle a submit of a
Form
component.
1
import
React
from
'react'
2
import
{
Form
}
from
'react-advanced-form'
3
4
export
default
class
ExampleForm
extends
React
.
Component
{
5
render
()
{
6
return
(
7
<
Form
action
=
{
this
.
registerUser
}
>
8
{
/* ... */
}
9
</
Form
>
10
)
11
}
12
}
Copied!
The
action
prop expects a function which returns a Promise. By returning the latter Form can properly react to the Promise status, which is a submit request status at the same time.
1
import
React
from
'react'
2
import
{
Form
}
from
'react-advanced-form'
3
4
export
default
class
ExampleForm
extends
React
.
Component
{
5
registerUser
=
(
{
serialized
,
fields
,
form
}
)
=>
{
6
return
fetch
(
API_URL
,
{
7
method
:
'POST'
,
8
body
:
JSON
.
stringify
(
serialized
),
9
})
10
}
11
12
render
()
{
13
return
(
14
<
Form
action
=
{
this
.
registerUser
}
>
15
{
/* ... */
}
16
</
Form
>
17
)
18
}
19
}
Copied!
Read more about the
action
prop.
Getting started - Previous
Applying validation
Next - Architecture
Argument properties
Last modified
3yr ago
Copy link