{"action":"closed","issue":{"url":"https://api.github.com/repos/ant-design/ant-design/issues/3566","repository_url":"https://api.github.com/repos/ant-design/ant-design","labels_url":"https://api.github.com/repos/ant-design/ant-design/issues/3566/labels{/name}","comments_url":"https://api.github.com/repos/ant-design/ant-design/issues/3566/comments","events_url":"https://api.github.com/repos/ant-design/ant-design/issues/3566/events","html_url":"https://github.com/ant-design/ant-design/issues/3566","id":185006524,"number":3566,"title":"Select的labelInValue属性的初始化值，和form required校验冲突的问题","user":{"login":"wufeng87","id":1686808,"avatar_url":"https://avatars.githubusercontent.com/u/1686808?v=3","gravatar_id":"","url":"https://api.github.com/users/wufeng87","html_url":"https://github.com/wufeng87","followers_url":"https://api.github.com/users/wufeng87/followers","following_url":"https://api.github.com/users/wufeng87/following{/other_user}","gists_url":"https://api.github.com/users/wufeng87/gists{/gist_id}","starred_url":"https://api.github.com/users/wufeng87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wufeng87/subscriptions","organizations_url":"https://api.github.com/users/wufeng87/orgs","repos_url":"https://api.github.com/users/wufeng87/repos","events_url":"https://api.github.com/users/wufeng87/events{/privacy}","received_events_url":"https://api.github.com/users/wufeng87/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-25T02:58:28Z","updated_at":"2016-10-25T06:19:46Z","closed_at":"2016-10-25T06:19:46Z","body":"代码如下：\r\n如果initialValue设置为null，Select会报错；\r\n如果initialValue设置为{label:null, value:null}，form的required校验会认为他不是一个空值。\r\n\t\t    \t\r\n```\r\nimport React from 'react';\r\nimport {\r\n\tButton,\r\n\tForm,\r\n\tSelect\r\n} from 'antd';\r\n\r\nconst FormItem = Form.Item;\r\nconst Option = Select.Option;\r\n\r\nconst SelectTest = React.createClass({\r\n\tonValidate(){\r\n\t\tthis.props.form.validateFields((errors, values) => {\r\n\t\t\tconsole.log('errors:', errors)\r\n\t\t})\r\n\t},\r\n  \trender() {\r\n\t    const { getFieldProps} = this.props.form;\r\n\t    const testProps = getFieldProps('test',   {\r\n\t\t      \t\trules: [{ required: true , message: '请选择test', type:'object'}],\r\n\t\t      \t\tinitialValue: null//{label:null, value:null}\r\n\t\t    \t}\r\n\t\t    );\r\n\t    return (\r\n\t\t    <div style={{margin: 10}}>\r\n\t\t        <Form >\r\n\t\t          \t<FormItem label=\"test：\" required >\r\n\t\t                  \t<Select {...testProps} labelInValue >\r\n\t\t                      \t<Option value=\"0\">111</Option>\r\n\t\t\t\t                <Option value=\"1\">222</Option>\r\n\t\t\t\t                <Option value=\"2\">333</Option>\r\n\t\t                  \t</Select>\r\n\t\t           \t</FormItem>\r\n\t\t        </Form>\r\n\t\t        <Button onClick={this.onValidate}>校验</Button>\r\n\t\t    </div>\r\n\t    );\r\n  \t}\r\n});\r\nvar NewApp = Form.create()(SelectTest);\r\nmodule.exports = NewApp;\r\n\r\n```"}}
{"actor":{"display_login":"wufeng87"}}