Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit be5094d

Browse files
committed
Adding (temporarily) onBeforeSubmit prop to <Form> (+ docs). Fixes #637
1 parent 882fdd0 commit be5094d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docs/api/Form.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,5 +231,17 @@ _(Function)_ Provides the dispatcher for the `<Form>`'s store.
231231
/>
232232
```
233233

234+
## `onBeforeSubmit={(event) => ...}`
235+
_(Function)_ Called every time a `submit` event is emitted from the form.
236+
237+
(since: 1.6.1 - note: this is temporary and likely to be removed in version 2.0)
238+
239+
```jsx
240+
<Form
241+
model="user"
242+
onBeforeSubmit={(event) => /* ... */}
243+
/>
244+
```
245+
234246
### Notes
235247
- This is most useful for use with `<LocalForm>`, and is primarily intended for `<LocalForm>`.

src/components/form-component.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const propTypes = {
4747
onChange: PropTypes.func,
4848
getRef: PropTypes.func,
4949
getDispatch: PropTypes.func,
50+
onBeforeSubmit: PropTypes.func,
5051

5152
// standard HTML attributes
5253
action: PropTypes.string,
@@ -337,8 +338,11 @@ function createFormClass(s = defaultStrategy) {
337338
formValue,
338339
onSubmit,
339340
validators,
341+
onBeforeSubmit,
340342
} = this.props;
341343

344+
if (onBeforeSubmit) onBeforeSubmit(e);
345+
342346
const formValid = formValue
343347
? formValue.$form.valid
344348
: true;

0 commit comments

Comments
 (0)