--- order: 11 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 { Option } = Select; class App extends React.Component { 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!' }], })( , )}
); } } const WrappedApp = Form.create({ name: 'coordinated' })(App); ReactDOM.render(, mountNode); ```