Skip to content

setFieldsValue没有考虑namePath的情况 #401

Description

@AM-young-fun

如antdesign里的设置带namepath的值,参考这个issue:
ant-design/ant-design#34863

What problem does this feature solve?

如Form.List导致的name path.

const [form] = useForm();
...
<Form form={form}>
  <Form.List>
  {
    fields => {
      return fields.map(field => {
        return <Form.Item name=[field.name, 'userName']><Input /></Form.Item>
      })
    }
  }
  </Form.List>
<Form>

form.setFieldsValue 这个api由于只能传Record<string, any> ,没法做到 处理NamePath是 (string|number)[] 类型的情况

What does the proposed API look like?

form.setFieldsValue((): [NamePath, Value][] => {
  return  [
    [[field.name, 'userName'], 'XiaoMing'],
    [[field.name, 'gender'], 'Male'],
  ];
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions