React-hook-form: <input name="name[]" ref={register} /> 数据不正确

Created on 21 Aug 2019  ·  3Comments  ·  Source: react-hook-form/react-hook-form

Describe the bug
name 为这个形式时,浏览器默认在表单提交时是一个数组形式的数据.
但是当前提交表单显示的数据 为{"telephone":{"":"123"},"name":{"":"234"}}
具体情况见链接
https://codesandbox.io/s/react-hook-form-custom-input-m1br1

question

Most helpful comment

This way is really effective
I will close this issue
I wish you a happy life 🙏

All 3 comments

@flycj You need to specify an index in the array, like this.

name="telephone[0]"
name="telephone[1]"

@flycj You need to specify an index in the array, like this.

name="telephone[0]"
name="telephone[1]"

Thank you very much.
I will try this way right away.

This way is really effective
I will close this issue
I wish you a happy life 🙏

Was this page helpful?
0 / 5 - 0 ratings