Search the documentation

Type to search page titles, component names and descriptions.

    Data Entry

    RecordForm

    A native form described as data.

    import { FormActions, FormGrid, RecordForm } from 'faifo-design'

    RecordForm renders a native form from a list of fields: the application supplies translated labels, values and errors, not markup. FormGrid lays out one group of fields and FormActions draws the action row for a form whose <form> element belongs to the caller.

    #When to use

    • Use it for creating and editing one record.
    • A group measures its own width: three peer fields per row in a wide container, one column on a phone.
    • A domain prerequisite can disable submission while the fields and the error stay reachable.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Record form

    Application supplies translated labels and values, not form markup.

    Main information

    Cancel
    Show codeHide code
    import { RecordForm, Surface } from 'faifo-design'
    
    export const Example = () => (
      <Surface
        title="Main information"
        body={
          <RecordForm
            action="#record-form"
            fields={[
              { id: 'record-name', name: 'name', label: 'Display name', value: 'Mùa Hạ Riverside' },
              {
                id: 'record-status',
                name: 'status',
                label: 'Lifecycle',
                type: 'select',
                value: 'ready',
                options: [
                  { value: 'draft', label: 'Draft' },
                  { value: 'ready', label: 'Ready' },
                ],
              },
              {
                id: 'record-note',
                name: 'note',
                label: 'Internal note',
                type: 'textarea',
                value: 'Migration approved by the operations team.',
                span: 'full',
              },
            ]}
            submitLabel="Save record"
            cancelHref="#patterns"
            cancelLabel="Cancel"
          />
        }
      />
    )

    #Form grid in sections

    A form split into sections lays each group out as a record form does: three peer fields per row once the group is 52rem wide, one column on a phone. Repeated groups carry an id so their fields say whose they are. FormActions closes the form with the record form's action row; a step back skips the required checks.

    Lead guest

    Second guest

    Show codeHide code
    import { Button, Field, FormActions, FormGrid, Section, Stack } from 'faifo-design'
    
    export const Example = () => (
      <form action="#form-grid" method="post">
        <Stack
          items={[
            <Stack
              divided
              items={['Lead guest', 'Second guest'].map((title, index) => (
                <Section
                  id={`form-grid-guest-${index + 1}`}
                  title={title}
                  body={
                    <FormGrid
                      columns={3}
                      items={[
                        <Field
                          id={`form-grid-name-${index}`}
                          name={`guest-${index}-name`}
                          label="Full name"
                          required
                        />,
                        <Field
                          id={`form-grid-birth-${index}`}
                          name={`guest-${index}-birth`}
                          label="Date of birth"
                          type="date"
                          required
                        />,
                        <Field
                          id={`form-grid-document-${index}`}
                          name={`guest-${index}-document`}
                          label="Document"
                          type="select"
                          value="passport"
                          options={[
                            { value: 'passport', label: 'Passport' },
                            { value: 'id', label: 'National ID' },
                          ]}
                        />,
                        <Field
                          id={`form-grid-note-${index}`}
                          name={`guest-${index}-note`}
                          label="Note"
                          type="textarea"
                          span="full"
                        />,
                      ]}
                    />
                  }
                />
              ))}
            />,
            <FormActions
              actions={[
                <Button label="Continue" variant="primary" type="submit" name="step" value="2" />,
                <Button label="Back" type="submit" name="step" value="0" formNoValidate />,
              ]}
            />,
          ]}
        />
      </form>
    )

    #Record form · peer groups, one save

    A single native form groups identity and contact inside one working Surface.

    Property

    General information

    Address and contact

    Show codeHide code
    import { RecordForm, Surface } from 'faifo-design'
    
    export const Example = () => (
      <Surface
        title="Property"
        body={
          <RecordForm
            action="#record-form-groups"
            fields={[]}
            groups={[
              {
                id: 'sample-identity',
                title: 'General information',
                fields: [{ id: 'group-code', name: 'code', label: 'Code', value: 'HOTEL' }],
              },
              {
                id: 'sample-contact',
                title: 'Address and contact',
                fields: [
                  {
                    id: 'group-email',
                    name: 'email',
                    label: 'Reservations email',
                    type: 'email',
                    value: 'reservations@example.test',
                  },
                ],
              },
            ]}
            submitLabel="Save property"
          />
        }
      />
    )

    #Record form · three peer fields

    Three columns in a wide form (56rem or more), the default layout in smaller containers, and one column on mobile. Field labels and native submission remain component-owned.

    Add purchase line

    Show codeHide code
    import { RecordForm, Surface } from 'faifo-design'
    
    export const Example = () => (
      <Surface
        title="Add purchase line"
        body={
          <RecordForm
            action="#record-form-three-columns"
            columns={3}
            fields={[
              {
                id: 'purchase-product',
                name: 'product',
                label: 'Product',
                type: 'select',
                options: [
                  {
                    value: 'carton',
                    label: 'Shipping carton · 30 × 20 × 15cm',
                  },
                ],
              },
              {
                id: 'purchase-quantity',
                name: 'quantity',
                label: 'Quantity',
                type: 'number',
                value: '1',
                required: true,
              },
              {
                id: 'purchase-price',
                name: 'price',
                label: 'Unit price',
                type: 'number',
                value: '0',
                required: true,
              },
            ]}
            submitLabel="Add line"
          />
        }
      />
    )

    #Record form · blocked submission

    A domain prerequisite can disable submission while recipient fields and error feedback remain accessible.

    Invoice

    • Configure charge rules before issuing the invoice.
    Show codeHide code
    import { RecordForm, Surface } from 'faifo-design'
    
    export const Example = () => (
      <Surface
        title="Invoice"
        body={
          <RecordForm
            action="#record-form-submit-blocked"
            fields={[{ id: 'blocked-recipient', name: 'recipient', label: 'Recipient', value: 'Guest' }]}
            submitLabel="Issue invoice"
            unsavedPrompt="Discard this draft?"
            submitDisabled
            errors={['Configure charge rules before issuing the invoice.']}
          />
        }
      />
    )

    #Contract

    #Fields in the sections of a longer form

    A form split into named sections (a check-in declaring each guest, a profile with an address block) lays each section's fields with FormGrid, not a Stack of fields or a generic Grid:

    <Section id="check-in-guest-2" title="Second guest" body={
      <FormGrid columns={3} items={[nameField, birthField, genderField, documentField, numberField, nationalityField]} />
    } />
    • FormGrid renders form-fields around the form grid and measures its own width. With columns={3} it lays three fields per row once that width is at least 52rem on desktop, which a default-size dialog's body reaches; narrower containers keep the two-column grid and a phone stacks them. A default dialog is wide enough: do not enlarge the dialog to get three columns.
    • The grid owns the 16px row and 24px column gaps (--faifo-gap-form-row, --faifo-gap-form-column); each field keeps its label, help and error. A span="full" field such as a note keeps one cell's label width, so its label lines up with the first column. A field whose label is hidden (a DropZone names itself inside the zone) has no label track: its zone, help and error take the whole row.
    • A cell is about a third of the dialog: keep labels, option labels and field messages short enough for it. Put an explanation once in the section's muted text or the form notice, not as help under every cell.
    • Give each repeated section an id. Section then renders aria-labelledby from its title, so a screen reader distinguishes the second guest's "Full name" from the first's.
    • FormGrid does not render a <form>; the enclosing form owns submission. RecordForm.columns={3} remains the choice for a single form without sections.
    • Close such a form with FormActions, the record form's own action row (divider, end alignment, ActionGroup), rather than a Stack or Inline of buttons. Put the primary command first: Enter submits a native form's first submit button. A step back in a multi-step form is a submit Button with formNoValidate, so a required field the current step has not filled does not stop it; the server still validates whatever is submitted.
    • On a page, such a form sits inside a titled Surface (one per step of a multi-step form), never on the page canvas; the record's place among the steps is a StagePath in RecordPage.path.

    #Full-page native drafts

    RecordForm.unsavedPrompt opts a full-page native form into the KetSuite host draft guard; initialDraft marks values retained after a refused submission. The host compares submitted controls (including relation/date hidden values) to the mounted baseline. Modified forms use the public centred in-app ConfirmDialog before links, other forms and history traversal; reload/close uses the browser unload prompt. Submitting the guarded form proceeds normally. A declined history traversal restores the draft URL as a history entry and keeps the mounted fields. Modal forms keep their existing modal owner. This requires the KetSuite backend runtime. The KetSuite compatibility ui.RecordForm adapter forwards the same unsavedPrompt and initialDraft hooks; it does not introduce a separate draft store.

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #FormActionsComponent

    The record form's action row for a form whose <form> belongs to the caller, beside the groups that FormGrid lays out: a multi-step form whose step needs Back as well as Continue, say. It draws the same divider and alignment as RecordForm's own row. Put the primary command first.

    PropertyDescriptionTypeDefault
    actionsrequiredThe form's commands, the one Enter submits first: a native form submits its first submit button.readonly JSXChild[]–
    label–string | null–

    #FormGridComponent

    The record form's field grid for one group of a form split into sections (a dialog's steps, a record's groups). The group measures its own width, so a section of a dialog lays its fields out the way a record form does without a record form around it.

    PropertyDescriptionTypeDefault
    itemsrequiredFields of one group of a larger form; the <form> around the groups belongs to the caller.readonly JSXChild[]–
    columnsThree peer fields per row once the group itself is 52rem wide, as a default-size dialog is.2 | 3–

    #RecordFormComponent

    PropertyDescriptionTypeDefault
    id–string | null–
    actionrequired–string–
    method–'get' | 'post''post'
    fieldsrequired–readonly FieldProps[]–
    groupsPeer groups in the same native form and save, inside its containing working Surface.readonly { id: string; title: string; description?: string; fields: readonly FieldProps[] }[]–
    columnsThree peer fields on wide forms; narrow containers retain the single-column layout.2 | 3–
    submitLabelrequired–string–
    submitVariant–ActionVariant'primary'
    submitDisabledKeep the fields editable while validation or a domain prerequisite prevents submission.boolean–
    unsavedPromptOpt a full-page native form into the host unsaved-draft guard.string–
    initialDraftA refused submission still contains an unsaved draft on first render.boolean–
    cancelHref–string | null–
    cancelLabel–string | null'Cancel'
    errors–readonly string[]–
    hidden–Record<string, string | readonly string[]>–
    applyOnInputA GET filter form without a submit step: the runtime submits a choice at once and typed text after a pause. The submit button stays only as a hidden default button, so Enter still applies at once.boolean–

    #Types

    #FormActionsProps

    The properties of FormActions, listed above.

    #FormGridProps

    The properties of FormGrid, listed above.

    #RecordFormProps

    The properties of RecordForm, listed above.

    #Hooks

    The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.

    • record-form
    • form-errors
    • form-fields
    • form-grid
    • form-actions