Skip to main content

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.

NameTypeDefaultDescription
source (required)string—Name of the array field on the record
choicesChoices—Enum of the items ({value, label, color?, icon?}); without it the raw values are shown
iconsKeystring—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:

itemsComponent
type: 'object', outside a listSchemaObjectArrayField
type: 'object', inside a listNothing — object arrays are not rendered as a column
carries a referenceSchemaReferenceArrayField
anything elseChipArrayField

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" }]
}
}
class Product(models.Model):
tags = ArrayField(models.CharField(max_length=32), blank=True, default=list)

See also​