SchemaObjectArrayInput
Collects a repeatable list of objects — one block of inputs per item, with add and remove controls.
Use it for lines that belong to the record itself (order items, price tiers). To pick existing records of another resource use SchemaArrayInput.
Example
<SchemaObjectArrayInput source="items" items={orderSchema.fields.items.items} />
Props
| Name | Type | Default | Description |
|---|---|---|---|
source (required) | string | — | Path to the array in the form record; the last segment becomes the box target |
items (required) | ItemFieldSchema | FieldSchema | — | Schema of one item; its properties become the inputs |
label | string | ReactElement | false | label from the schema | Heading of the array box |
Schema mapping
type: "array" whose items.type is object:
{"name": "items", "type": "array",
"items": {"type": "object",
"properties": [
{"name": "product", "type": "integer", "format": "relation", "reference": "eshop/product"},
{"name": "quantity", "type": "integer", "required": true}
]}}
- Python
- Ruby
A nested serializer with many=True; the admin serializer creates, updates and deletes the rows
to match what the form submitted:
class OrderItemSerializer(AdminModelSerializer):
class Meta:
model = OrderItem
fields = ["id", "product", "quantity"]
class OrderSerializer(AdminModelSerializer):
items = OrderItemSerializer(many=True)
class Meta:
model = Order
fields = ["id", "number", "items"]
caution
Keep the primary key in the nested serializer's fields. Without it every save is read as
“delete all rows and create new ones”, which loses the ids the rest of the system references.
See also
- SchemaObjectArrayField — the display counterpart
- SchemaObjectInput — a single nested object