ErlangFormDocs v1.0.0
Basic fields

Select

String options, inferred enums, and dependent choices.

Use a string schema with fieldConfig.options. Each option has a visible label and a string value; selecting Indonesia in this example stores country: "id". Use z.enum() when validation must restrict the value to the available choices.

Usage

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

example.tsx
const schema = z.object({ country: z.enum(["id", "jp"]) });

<ErlForm
  form={form}
  schema={schema}
  fieldConfig={{
    country: {
      options: [
        { label: "Indonesia", value: "id" },
        { label: "Japan", value: "jp" },
      ],
    },
  }}
/>

Inferred choices

z.enum(["id", "jp"]) generates select options automatically. Supply options explicitly to customize their labels while keeping the same values. Numeric enums do not become selects automatically.

options can also be a synchronous callback for dependent choices. A selected value that disappears from the option list is reset to an empty string. Use type radio for a radio group.

On this page