Skip to content

How does Form.useForm work with array #5788

@lenlch

Description

@lenlch
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

I dunno how to define the v-bind on form item and rule

What does the proposed API look like?

within an edit table #bodyCell={record, index}
<template>
  <a-form>
    <a-table>
      <template #bodyCell="{ column, index, record }">
        <template v-if="column.key === 'name'">
          <a-form-item v-bind="myFrom.validateInfos[`lists.${index}.role`]">
            <a-input v-model:value="record.name" />
          </a-form-item>
        </template>
      </template>
    <a-table>
  </a-form>
</template>

<script lang='ts' setup>
const myFrom = Form.useForm(
  reactive({
    lists: [{ name: undefined }]
  }),
  reactive({
    'lists.index.name': [{ required: true, message: 'required' }]
  })
)
</script>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions