Skip to content
This repository was archived by the owner on Nov 26, 2021. It is now read-only.

Commit 171bda7

Browse files
committed
add formDidChange
1 parent 0f5a583 commit 171bda7

File tree

7 files changed

+22
-3
lines changed

7 files changed

+22
-3
lines changed

README-zh_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,4 @@ return (
160160
| removeValues | function | | true | 删除一个或多个值 |
161161
| addSchemas | function | | false | 添加一个或多个验证规则 |
162162
| removeSchemas | function | | true | 删除一个或多个验证规则 |
163+
| formDidChange | function | | | 回调函数 |

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ return (
149149
| removeValues | function | | true | Remove one or more value |
150150
| addSchemas | function | | false | Add one or more validation rules |
151151
| removeSchemas | function | | true | Remove one or more validation rules |
152+
| formDidChange | function | | | Callback |
152153

153154
You can either pass in `values` as an argument, or call the `init` method when the form is initialized.
154155

example/ChildForm.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class ChildForm extends Component {
1818
constructor(props) {
1919
super(props);
2020
// Initializes the values
21-
props.formControl.init({
21+
const { formControl } = props;
22+
formControl.init({
2223
url: '',
2324
});
2425
}

lib/FormControl.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/FormControl.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-validate-framework",
3-
"version": "0.9.6",
3+
"version": "0.9.7",
44
"description": "React validation framework.",
55
"main": "lib/index.js",
66
"scripts": {

src/FormControl.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export default (schemas, methods) => FormComponent => (
252252
this.setState({
253253
fields,
254254
});
255+
this.formDidChange();
255256
};
256257

257258
/**
@@ -269,6 +270,7 @@ export default (schemas, methods) => FormComponent => (
269270
this.setState({
270271
fields,
271272
});
273+
this.formDidChange();
272274
return this;
273275
};
274276

@@ -311,6 +313,7 @@ export default (schemas, methods) => FormComponent => (
311313
this.setState({
312314
fields,
313315
});
316+
this.formDidChange();
314317
return this;
315318
};
316319

@@ -327,6 +330,7 @@ export default (schemas, methods) => FormComponent => (
327330
this.setState({
328331
fields,
329332
});
333+
this.formDidChange();
330334
return this;
331335
};
332336

@@ -351,6 +355,9 @@ export default (schemas, methods) => FormComponent => (
351355
return this.validateByNames(...names);
352356
};
353357

358+
// After change
359+
formDidChange = () => {};
360+
354361
render() {
355362
return (
356363
<FormComponent

0 commit comments

Comments
 (0)