Skip to main content

SchemaArrayInput

Collects an array of scalars, enum values or references — the shape depends on items.

It is a dispatcher, not a widget of its own: an array of references becomes an autocomplete multi-select, an array of enum values a chip multi-select, and anything else a comma-separated text input. For an array of objects the schema dispatcher picks SchemaObjectArrayInput instead.

Example​

{/* References — autocomplete multi-select */}
<SchemaArrayInput source="categories" items={{type: 'integer', reference: 'eshop/category'}} />

{/* Enum values — chip multi-select */}
<SchemaArrayInput source="tags" items={{type: 'string', format: 'choices', enum: tagChoices}} />

Props​

NameTypeDefaultDescription
source (required)string—Name of the field in the form record
items (required)ItemFieldSchema | FieldSchema—Schema of one item; decides which variant is rendered
labelstring | ReactElement | falselabel from the schemafalse hides the label
validateValidator | Validator[]from the schemaReact Admin validators
defaultValueunknownfrom the schemaInitial value in a create form

What items selects​

itemsRendered as
has a referenceAutocomplete multi-select over the referenced resource; a tree picker when format is tree-relation
format: "choices" with an enumMulti-select showing the selected values as colored chips
anything elseText input parsed by splitting on commas

Reference arrays​

An array of references reads the same options.relation keys as SchemaReferenceInput: filters and sort shape the autocomplete results, showCreateButton adds an inline create button, and parent builds the tree for tree-relation. They live on items.options.relation, not on the array field itself.

caution

preserveOrder defaults to true only while no sort is set. Declaring a sort on the relation means the stored order is no longer what the user sees.

Schema mapping​

type: "array" whose items are not objects:

{"name": "categories", "type": "array",
"items": {"type": "integer", "format": "relation", "reference": "eshop/category",
"options": {"relation": {"showCreateButton": true}}}}

A many-to-many relation:

class Product(models.Model):
categories = models.ManyToManyField(Category, related_name="products")

See also​