Skip to content

Commit

Permalink
docs: update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
benjycui authored and afc163 committed Jul 4, 2016
1 parent 1f0c26b commit 7669887
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions components/form/demo/dynamic-form-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ let Demo = React.createClass({
},
submit(e) {
e.preventDefault();
console.log(this.props.form.getFieldsValue());
this.props.form.validateFields((errors, values) => {
if (errors) {
console.log(errors);
}
console.log(values);
});
},
render() {
const { getFieldProps, getFieldValue } = this.props.form;
Expand All @@ -52,7 +57,14 @@ let Demo = React.createClass({
const formItems = getFieldValue('keys').map((k) => {
return (
<Form.Item {...formItemLayout} label={`好朋友${k}`} key={k}>
<Input {...getFieldProps(`name${k}`)} style={{ width: '80%', marginRight: 8 }} />
<Input {...getFieldProps(`name${k}`, {
rules: [{
required: true,
whitespace: true,
message: '你好友的名字捏!',
}],
})} style={{ width: '80%', marginRight: 8 }}
/>
<Button onClick={() => this.remove(k)}>删除</Button>
</Form.Item>
);
Expand Down

0 comments on commit 7669887

Please sign in to comment.