DataForm renders an auto-generated form for viewing and editing the fields
of a data item, driven by a fields and form layout configuration. Use it to
edit items of a dataset, often alongside DataViews.
import { DataForm } from '@wordpress/dataviews';
LinksPermalink to this section
PropsPermalink to this section
| Name | Default | Description |
|---|---|---|
data Required |
The item being edited. | |
fields Required |
The field definitions for the item. | |
form Required |
The form configuration: which fields to render and with which layout. | |
onChange Required |
Callback invoked when the user edits a field, receiving the partial
item returned by the field’s | |
validity |
The validity state of the form’s fields, keyed by field id. |
ExamplesPermalink to this section
Layout CardPermalink to this section
const LayoutCard = () => <DataForm withHeader withSummary isCollapsible />;
Layout DetailsPermalink to this section
const LayoutDetails = () => <DataForm />;
Layout PanelPermalink to this section
const LayoutPanel = () => <DataForm openAs="default" showPlaceholderIfEmpty={false} disabled={false} />;
Layout RegularPermalink to this section
const LayoutRegular = () => <DataForm disabled={false} />;
Layout RowPermalink to this section
const LayoutRow = () => <DataForm alignment="default" />;
Layout MixedPermalink to this section
const LayoutMixed = () => <DataForm />;
ValidationPermalink to this section
const Validation = () => <DataForm
layout="regular"
required
elements="sync"
custom="sync"
pattern={false}
minMax={false} />;
Validation Panel Error IndicatorPermalink to this section
const ValidationPanelErrorIndicator = () => <DataForm />;
VisibilityPermalink to this section
const Visibility = () => <DataForm />;
Data AdapterPermalink to this section
const DataAdapter = () => <DataForm />;