--- order: 12 title: zh-CN: 表单联动 en-US: Coordinated Controls --- ## zh-CN 使用 `setFieldsValue` 来动态设置其他控件的值。 ## en-US Use `setFieldsValue` to set other control's value programmaticly. ````jsx import { Form, Select, Input, Button } from 'antd'; const FormItem = Form.Item; const Option = Select.Option; const App = Form.create()(React.createClass({ handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { console.log('Received values of form: ', values); } }); }, handleSelectChange(value) { console.log(value); this.props.form.setFieldsValue({ note: `Hi, ${value === 'male' ? 'man' : 'lady'}!`, }); }, render() { const { getFieldDecorator } = this.props.form; return (
{getFieldDecorator('note', { rules: [{ required: true, message: 'Please input your note!' }], })( )} {getFieldDecorator('gender', { rules: [{ required: true, message: 'Please select your gender!' }], onChange: this.handleSelectChange, })( )}
); }, })); ReactDOM.render(, mountNode); ````