ErlangFormDocs v1.0.0
Structured data

Tuple

Render fixed positions and tuples inside arrays.

Item #1

A tuple has fixed positions with individual types. Unlike an array, the tuple itself has no add/remove controls. The example also places tuples inside a dynamic array.

Usage

Use your form instance from useForm. See the initial setup.

example.tsx
const schema = z.object({ point: z.tuple([z.string(), z.number()]) });

<ErlForm
  form={form}
  schema={schema}
  fieldConfig={{
    point: {
      0: { label: "Point name" },
      1: { label: "Value" },
    },
  }}
/>

Configure positions using numeric keys 0, 1, and so on. Position callbacks receive the parent tuple; internal paths use indexes such as points[0][1].

The renderer only reads fixed schema positions. A tuple rest schema does not create a dynamic editor for extra positions. Supply complete defaultValues. clearOnHide resets a tuple to an empty array, not to its original tuple values.

On this page