Home > other >  Ant Design Form field with array of objects
Ant Design Form field with array of objects

Time:11-03

I want to edit an entity with one-to-many relation

{
  id: 1,
  title: 'Title',
  tags: [
    { id: 1 },
    { id: 2 },
  ],
}

With the code

<Form.Item
      name={["tags", "id"]}
    >

      <Select mode={'multiple'} {...selectProps} />
    </Form.Item>

On submit I get such object:

{
  id: 1,
  title: 'Title',
  tags: { id: [1, 2]},
}

How can I get tags as array of objects?

CodePudding user response:

Try using the normalize callback on Form.Item

  • Related