You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Tip**: `Create` and `Edit` inject more props to their child. So `SimpleForm` also expects these props to be set (but you shouldn't set them yourself):
713
+
**Tip**: `Create` and `Edit` inject more props to their child. So `SimpleForm` also expects these props to be set (you should set them yourself only in particular cases like the [submission validation](#submission-validation)):
714
714
715
715
*`save`: The function invoked when the form is submitted.
716
716
*`saving`: A boolean indicating whether a save operation is ongoing.
**Important**: Note that asynchronous validators are not supported on the `<ArrayInput>` component due to a limitation of [react-final-form-arrays](https://github.com/final-form/react-final-form-arrays).
1331
1331
1332
+
## Submission Validation
1333
+
1334
+
The form can be validated by the server after its submission. In order to display the validation errors, a custom `save` function needs to be used:
**Tip**: The shape of the returned validation errors must correspond to the form: a key needs to match a `source` prop.
1372
+
1332
1373
## Submit On Enter
1333
1374
1334
1375
By default, pressing `ENTER` in any of the form fields submits the form - this is the expected behavior in most cases. However, some of your custom input components (e.g. Google Maps widget) may have special handlers for the `ENTER` key. In that case, to disable the automated form submission on enter, set the `submitOnEnter` prop of the form component to `false`:
Copy file name to clipboardexpand all lines: packages/ra-core/src/form/useInitializeFormWithRecord.ts
+8-4
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,14 @@ const useInitializeFormWithRecord = record => {
19
19
// Disable this option when re-initializing the form because in this case, it should reset the dirty state of all fields
20
20
// We do need to keep this option for dynamically added inputs though which is why it is kept at the form level
21
21
form.setConfig('keepDirtyOnReinitialize',false);
22
-
// Ignored until next version of final-form is released. See https://github.com/final-form/final-form/pull/376
23
-
// @ts-ignore
24
-
form.restart(initialValuesMergedWithRecord);
25
-
form.setConfig('keepDirtyOnReinitialize',true);
22
+
// Since the submit function returns a promise, use setTimeout to prevent the error "Cannot reset() in onSubmit()" in final-form
23
+
// It will not be necessary anymore when the next version of final-form will be released (see https://github.com/final-form/final-form/pull/363)
24
+
setTimeout(()=>{
25
+
// Ignored until next version of final-form is released. See https://github.com/final-form/final-form/pull/376
0 commit comments