Submit handling
If you want Liform React Final to just display your Symfony Form and send back the data, you are already done here.
Just return a 201
(or any other 2xx
) status with a Location
header pointing to another endpoint when you are satisfied, or report errors with 4xx
status.
If you want to hook in on the submit handling on the client side you can use the following callbacks:
Prop name | Description |
---|---|
action | Url where the form data is sent to. |
prepareRequest | Callback that will receive the values as first, the LiformApi as second and the default prepareRequest callback as third argument.Should return fetch() init options object. |
handleSubmitResponse | Callback that will receive the submit handling callbacks below, the callbacks for the Final Form Submit Promise and the Response |
handleSubmitError | Callback that will receive the callbacks for the Final Form Submit Promise and the error message. |
handleSubmitRedirectResponse | Per definition 3xx responses are neither failed nor completed, but require extra steps. If you want to handle those, define your callback here. It will receive the callbacks for Final Form Submit Promise and the Response. |
onSubmitRedirect | This will be called when there is a location header. It will receive the callbacks for Final Form Submit Promise, the location and the Response. |
onSubmitSuccess | This will be called for successful application/json responses. It will receive the callbacks for Final Form Submit Promise, the response data and the Response. |
onSubmitFail | Like onSubmitSuccess but for failed (4xx ) application/json responses. |
onSubmitHtmlResponse | This will be called for HTML responses. It will receive the callbacks for Final Form Submit Promise and the Response. |
If you don’t like the submit handling by this library at all, you can replace it altogether per buildSubmitHandler
prop:
<Liform {...liformProps} buildSubmitHandler={myBuildSubmitHandler}/>