FieldGroup#

@palmyralabs/rt-forms · src/palmyra/form/FieldGroup.tsx

Overview#

Registers a named group of fields with the enclosing PalmyraForm. Consumes FormManagerContext, asks the form manager for an IFieldGroupManager, and re-publishes it through FieldGroupManagerContext so that every descendant field widget can self-register.

PalmyraForm automatically wraps its children in a default FieldGroup name="_default", so you only need an explicit FieldGroup when you want multiple named groups in the same form (e.g. basic info / billing / shipping submitted together, or validation scoped per group).

Note: FieldGroup is used internally by PalmyraForm. It is not re-exported from the top-level barrel in the current release — import from the deep path if you need it directly. FieldGroupContainer (CSS grid wrapper, below) is re-exported and is what most layouts reach for.

Props — IFieldGroupCOptions#

interface IFieldGroupOptions  { name: string; }
interface IFieldGroupCOptions extends IFieldGroupOptions { children?: any; }

Ref — IFieldGroup#

interface IFieldGroup {}   // currently empty — reserved for future methods

Context#

  • Consumes: FormManagerContext — gets the parent form’s manager.
  • Publishes: FieldGroupManagerContext — descendants read from this to self-register.
// src/palmyra/form/FieldGroupContainer.tsx
interface FormFieldContainerInput {
  columns?: 2 | 3 | 4 | number;
  children: any;
}

Pure CSS-grid wrapper — applies py-field-group-container py-field-group-container-Ncolumns. It does not register a FieldGroup; it just arranges visible fields in columns.

Example — multiple named groups#

import { PalmyraForm, FieldGroup, FieldGroupContainer } from '@palmyralabs/rt-forms';
import { TextField } from '@palmyralabs/rt-forms-mantine';

<PalmyraForm>
  <FieldGroup name="primary">
    <FieldGroupContainer columns={2}>
      <TextField attribute="firstName" label="First name" required />
      <TextField attribute="lastName"  label="Last name"  required />
    </FieldGroupContainer>
  </FieldGroup>

  <FieldGroup name="billing">
    <FieldGroupContainer columns={2}>
      <TextField attribute="billingAddress" label="Billing address" />
      <TextField attribute="billingPostcode" label="Postcode" />
    </FieldGroupContainer>
  </FieldGroup>
</PalmyraForm>

Each group can be validated, reset, or read out as a discrete unit through the form manager exposed by PalmyraForm’s ref.