RepeaterField

A repeating section field that allows users to dynamically add and remove rows of fields. Each row is rendered using a customizable RowTemplate and the component tracks all row data as a list of dictionaries.

Basic Usage

<ArcadiaForm Model="model">
    <RepeaterField Label="Line Items"
                   @bind-Rows="model.LineItems"
                   MinRows="1"
                   MaxRows="10"
                   AddText="+ Add Line Item">
        <RowTemplate>
            <TextField Label="Description" @bind-Value="context.Values["description"]" />
            <NumberField Label="Quantity" @bind-Value="context.Values["quantity"]" />
        </RowTemplate>
    </RepeaterField>
</ArcadiaForm>

Parameters

ParameterTypeDefaultDescription
RowsList<Dictionary<string, object?>>new()The collection of row data, where each row is a dictionary of field names to values. Supports two-way binding.
RowsChangedEventCallback<List<Dictionary<string, object?>>>Callback invoked whenever a row is added or removed.
RowTemplateRenderFragment<RepeaterRowContext>?nullThe template used to render each repeater row. Receives a RepeaterRowContext.
MinRowsint0The minimum number of rows that must remain. The remove button is disabled at this count.
MaxRowsint?nullThe maximum number of rows allowed. Null means unlimited. The add button is disabled at this count.
AddTextstring"+ Add Row"The label displayed on the button that adds a new row.

Inherited from FieldBase

ParameterTypeDefaultDescription
Labelstring?nullVisible label displayed as the fieldset legend.
HelperTextstring?nullHelper text displayed below the repeater.
RequiredboolfalseWhether the field is required.
DisabledboolfalseWhether the add/remove buttons and all child fields are disabled.
ErrorsIReadOnlyList<string>?nullValidation errors to display.
SchemaFieldSchema?nullField schema definition for dynamic form generation.

RepeaterRowContext

The RowTemplate receives a RepeaterRowContext with the following properties:

PropertyTypeDescription
IndexintThe zero-based row index.
ValuesDictionary<string, object?>The row’s field values.

Validation

public class InvoiceModel
{
    [MinLength(1, ErrorMessage = "At least one line item is required.")]
    public List<Dictionary<string, object?>> LineItems { get; set; } = new();
}

Accessibility

  • Wrapped in a <fieldset> with a <legend> for proper grouping.
  • Each remove button has an aria-label identifying the row (e.g., “Remove row 1”).
  • The add button is disabled when MaxRows is reached.
  • The remove button is disabled when MinRows is reached.
  • Validation errors are linked via aria-describedby and announced with role="alert".