Skip to Content
APIInterfacesInterface: FieldArrayConfig<TFieldValues>

Hero Hook Form API v2.15.0


Hero Hook Form API / FieldArrayConfig

Interface: FieldArrayConfig<TFieldValues>

Defined in: types.ts:303 

Field array config for dynamic repeating field groups.

Description

Configuration for field arrays that support reordering, custom rendering, default values, and conditional fields within array items.

Extends

Type Parameters

TFieldValues

TFieldValues extends FieldValues

The form data type

Properties

label?

optional label: string

Defined in: types.ts:139 

Inherited from

DynamicSectionConfig.label


description?

optional description: string

Defined in: types.ts:140 

Inherited from

StringArrayFieldConfig.description


className?

optional className: string

Defined in: types.ts:141 

Inherited from

DynamicSectionConfig.className


isDisabled?

optional isDisabled: boolean

Defined in: types.ts:142 

Inherited from

DynamicSectionConfig.isDisabled


rules?

optional rules: RegisterOptions<TFieldValues, Path<TFieldValues>>

Defined in: types.ts:143 

Inherited from

Omit.rules


condition()?

optional condition: (values) => boolean

Defined in: types.ts:146 

Parameters

values

Partial<TFieldValues>

Returns

boolean

Inherited from

Omit.condition


dependsOn?

optional dependsOn: Path<TFieldValues>

Defined in: types.ts:147 

Inherited from

Omit.dependsOn


dependsOnValue?

optional dependsOnValue: unknown

Defined in: types.ts:148 

Inherited from

DynamicSectionConfig.dependsOnValue


group?

optional group: string

Defined in: types.ts:151 

Inherited from

DynamicSectionConfig.group


ariaLabel?

optional ariaLabel: string

Defined in: types.ts:154 

Inherited from

DynamicSectionConfig.ariaLabel


ariaDescribedBy?

optional ariaDescribedBy: string

Defined in: types.ts:155 

Inherited from

DynamicSectionConfig.ariaDescribedBy


type

type: "fieldArray"

Defined in: types.ts:305 


name

name: ArrayPath<TFieldValues>

Defined in: types.ts:307 

Field array name - must be an ArrayPath (points to an array field)


fields

fields: ZodFormFieldConfig<TFieldValues>[]

Defined in: types.ts:309 

Field configurations for each array item


min?

optional min: number

Defined in: types.ts:311 

Minimum number of items (default: 0)


max?

optional max: number

Defined in: types.ts:313 

Maximum number of items (default: 10)


addButtonText?

optional addButtonText: string

Defined in: types.ts:315 

Add button text (default: “Add Item”)


removeButtonText?

optional removeButtonText: string

Defined in: types.ts:317 

Remove button text (default: “Remove”)


enableReordering?

optional enableReordering: boolean

Defined in: types.ts:319 

Enable reordering of array items with up/down buttons (default: false)


reorderButtonText?

optional reorderButtonText: object

Defined in: types.ts:321 

Custom text for reorder buttons

up?

optional up: string

Text for move up button (default: ”↑“)

down?

optional down: string

Text for move down button (default: ”↓“)


defaultItem()?

optional defaultItem: () => any

Defined in: types.ts:328 

Function to create default item when adding new array item

Returns

any


readOnly?

optional readOnly: boolean

Defined in: types.ts:330 

When true, hide add button, remove buttons, and reorder buttons (display-only)


alwaysRegistered?

optional alwaysRegistered: boolean

Defined in: types.ts:332 

Whether this field array should always be registered (for conditional rendering)


renderItem()?

optional renderItem: (props) => ReactNode

Defined in: types.ts:334 

Custom render function for array items

Parameters

props
index

number

Item index (0-based)

field

{[key: string]: any; id: string; }

Field array item with id

field.id

string

fields

object[]

All fields in the array

children

ReactNode

Rendered field elements

onRemove

() => void

Remove this item

onMoveUp

() => void

Move item up

onMoveDown

() => void

Move item down

canRemove

boolean

Whether item can be removed

canMoveUp

boolean

Whether item can move up

canMoveDown

boolean

Whether item can move down

Returns

ReactNode


renderAddButton()?

optional renderAddButton: (props) => ReactNode

Defined in: types.ts:357 

Custom render function for add button

Parameters

props
onAdd

() => void

Add new item

canAdd

boolean

Whether new item can be added

Returns

ReactNode