-
Notifications
You must be signed in to change notification settings - Fork 292
Support nested fields and arrays #48
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
Conversation
@williamkhshea just saw this. Upon validate, does this also return the same nested object? IE, on submit, will it return
If it's doing this, then I'll close my PR in favor of this one. |
@alexggordon Yes, and errors will be nested object as well. I have added an example called "nested-field" in the example folder. You can check it out and see what how the outputs look like. |
Sweet job @williamkhshea. |
👍 |
@@ -62,6 +62,7 @@ | |||
"babel-runtime": "6.x", | |||
"dom-scroll-into-view": "1.x", | |||
"hoist-non-react-statics": "1.x", | |||
"lodash": "^4.17.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use lodash(especially too big for mobile), or at least use lodash-xx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yiminghe OK, I will update to use custom build of lodash
@yiminghe How can I ignore the lint style checking for the lodash custom build file before I commit? |
I mean something like https://www.npmjs.com/package/lodash.get |
@yiminghe Dependencies updated. Please review. |
@afc163 Object-path uses only dot notation for array path (i.e. 'a.0'), unlike lodash which also supports bracket notation (i.e. 'a[0]'). It creates problems when you want to have numbers as keys of an object, says in case of IDs. It gives you an array instead of object with keys as IDs. If you want to trim down the size of the libraries further, I would suggest you do a custom build on lodash get,has,set function and make an npm package, and I can use it as dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last change. please squash into one commit. ready to merge
thank you
b: ['7', '8'], | ||
})).to.be(true); | ||
form.resetFields(); | ||
expect(isEqual(form.getFieldValue('foo'), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(form.getFieldValue('foo')).to.eql({....})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yiminghe expect(...).to.eql does not handle sparse arrays (e.g. [undefined, 123]). See screenshot below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, squash into one commit, and force push please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yiminghe done
@yiminghe I should have cleaned up my code before submitting. Thanks for helping out. |
* support nested form item name by upgrade rc-form react-component/form#48 * Fix dynamic form demo
我在使用嵌套写法的时候,并没有生效:
|
@williamkhshea Can this bug be related to this PR? |
then setFieldsValue not work with nested assign, anyone know how to solve? |
@nanxiaobei please file a new issue and provide re-producible demo http://codepen.io/benjycui/pen/NdQdBw?editors=0011 |
|
me too,then i use setFiledsValue(()=>{setTimeout...}),Nevertheless, it seems to be successful, but there are still problems |
id再转一下string类型就OK了 |
如果有人想要 key 里面含有 . 的话, 参考 lodash/lodash#3529 (comment) |
See #47
In input form
this.props.form.getFieldsValue() 返回数据结构为