CxJS

FieldGroup

import { FieldGroup } from 'cx/widgets'; Copied

The FieldGroup widget is a pure container that allows controlling multiple form elements using shared properties like disabled, readOnly, and viewMode. Under the hood, FieldGroup is an alias for ValidationGroup.

<div>
  <div className="flex gap-4 mb-4">
    <Checkbox value={m.enabled}>Enabled</Checkbox>
    <Checkbox value={m.readOnly}>Read Only</Checkbox>
    <Checkbox value={m.viewMode}>View Mode</Checkbox>
  </div>
  <FieldGroup
    layout={LabelsLeftLayout}
    enabled={m.enabled}
    readOnly={m.readOnly}
    viewMode={m.viewMode}
  >
    <TextField label="First Name" value={m.firstName} required />
    <TextField label="Last Name" value={m.lastName} required />
    <Checkbox label="Status" value={m.active} text="Active" />
    <Button text="Submit" mod="primary" />
  </FieldGroup>
</div>

Toggle the checkboxes to see how enabled, readOnly, and viewMode affect all fields within the group.

Configuration

PropertyTypeDescription
enabledBooleanPropSet to false to disable all inner elements.
disabledBooleanPropSet to true to disable all inner elements.
readOnlyBooleanPropSet to true to make all inner elements read-only.
viewModeBooleanPropSet to true to set all child fields to view mode.
visitedBooleanPropSet to true to notify all children to report errors.
strictBooleanPropForce children to respect disabled, readOnly, viewMode flags.
tabOnEnterKeyBooleanPropSet to true to tab on Enter key for all children.
asteriskBooleanPropSet to true to add red asterisk for all required fields.
validBooleanPropBinding set to true if all child fields are valid.
invalidBooleanPropBinding set to true if any child field has validation error.
errorsPropBinding to store validation errors array.
isolatedBooleanPropSet to true to isolate from outer validation scopes.