ChipArrayField
Renders an array of scalar values as a row of chips.
It is the fallback for arrays: when the items are objects or references, the dispatcher picks SchemaObjectArrayField or SchemaReferenceArrayField instead.
Example
<ChipArrayField source="tags" />
// with an enum the raw values resolve to their label, colour and icon
<ChipArrayField source="channels" choices={channelChoices} iconsKey="channels" />
Props
On top of these it accepts the shared field props.
| Name | Type | Default | Description |
|---|---|---|---|
source (required) | string | — | Name of the array field on the record |
choices | Choices | — | Enum of the items ({value, label, color?, icon?}); without it the raw values are shown |
iconsKey | string | — | Key into the iconsMap on SchemaAdmin, giving each chip an icon |
It is the presence of choices — not a format flag — that switches on the enum branch. Inside a
datagrid, chips that have an icon collapse to icon-only, tooltipped glyphs; chips without one stay
as chips, ellipsized to the column width.
Chips never link anywhere — linkType is false. For clickable references use
SchemaReferenceField.
defaultFieldProvider fills both props from the item schema: choices from items.enum and
iconsKey from items.options.choices.iconsKey.
How an array is dispatched
defaultFieldProvider looks at schema.items, not at the array itself:
items | Component |
|---|---|
type: 'object', outside a list | SchemaObjectArrayField |
type: 'object', inside a list | Nothing — object arrays are not rendered as a column |
carries a reference | SchemaReferenceArrayField |
| anything else | ChipArrayField |
An array without items in its schema renders nothing at all.
Schema mapping
{
"name": "tags",
"type": "array",
"items": {
"type": "string",
"format": "choices",
"enum": [{ "value": "sale", "label": "Sale", "color": "success" }]
}
}
- Python
- Ruby
class Product(models.Model):
tags = ArrayField(models.CharField(max_length=32), blank=True, default=list)
See also
- SchemaArrayInput — the form counterpart
- SchemaObjectArrayField — arrays of objects
- SchemaArrayBox — an array laid out as a repeatable section