-
-
Notifications
You must be signed in to change notification settings - Fork 47.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How about getFieldProps
takes over all the properties of a form control
#1533
Comments
+1 Currently, this is an error-prone point |
I think it is ugly for writing or reading. Make Form more complex. |
+1 warning is important |
{
getFormControl(<Select {...props} />, {
name: 'select',
rules: [{ required: true }],
})
} or // like Form.create()(XxForm);
{
createFormControl({
name: 'select',
rules: [{ required: true }],
})(<Select {...props} />)
} Keep Component written in original way. |
Or this: import { Select } from 'antd';
// // like Form.create()(XxForm);
const FormSelect = Form.createControl({
name: 'select',
rules: [ ... ],
})(Select);
...
<FormItem>
<FormSelect {...props} />
</FormItem> |
👍 For the 1st step, should add warning messages for |
Prefer: #1533 (comment) For it looks like If you think it's OK, I will implement this feature in antd@2.0 |
最近这类问题又开始多起来了,应该是 antd 新增了用户所致。 |
@benjycui Need conclusion here. |
发现之前的回复没有了。。。。 |
+ getFieldDecorator('userName', { ... })(
<Input placeholder="请输入账户名"
- {...getFieldProps('userName', { ... })}
/>
+ ) And Also, |
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. |
Now,
getFieldProps
will take two arguments, then return some properties which will be transfered to form control.However, not all the developers know that
getFieldProps
has occupiedonChange
(andvalue
and maybe more event triggers). So, they may write something like this:It seems that
getFieldProps
is broken now. Actually, if we want to add an event handler toSelect
, we have to do this:A developer have to know what
getFieldProps
will return now. It is not easy, if you are not familiar withgetFieldProps
. Because the return value ofgetFieldProps
depends on the second argument.But.. If
getFieldProps
take over all the properties ofSelect
:We don't need to care about what will
getFieldProps
return. What does a developer need to know is: if you usegetFieldProps
, all the properties should be passed tooption.props
.After
getFieldProps
takes over all the properties, it can check those properties and throw some warning:option.props.defaultValue
, warn: 'Please setoption.initialValue
, instead of ...'option.props.defaultChecked
, warn: 'Please setoption.initialValue
andoptions. valuePropName
, instead of ...'The text was updated successfully, but these errors were encountered: