Skip to main content

SchemaObjectBox

Renders the properties of a nested object as if they were fields of the parent — a shipping address inside an order, a specification inside a product.

Use it when a has-one relation or an embedded object should be edited on the parent's form. For a list of such objects use SchemaArrayBox.

Example​

EditViewSchemaGenerator(box=Box(boxes=[
Box(label="Order", boxes=["number", "customer"]),
ObjectBox(
label="Shipping address",
target="shipping_address",
boxes=["street", "city", "postal_code", "country"],
),
]))

Schema fields​

FieldTypeDefaultDescription
object.target (required)string—Name of the object field on the parent record
boxesBoxItem[][]Properties of the object, named without the target. prefix
labelstring—Section heading; on its own it turns the card frame on
cardboolean | nullnullThree-state card frame — see Card frame
toolbarActions / bottomActionsActionDescriptor[]—The usual header and bottom slots

Behaviour​

  • The box installs a SourceContext that prefixes every child's source with the target, so a child declared as city binds to shipping_address.city. Write the children with their plain names.
  • Read-only views, and a target field marked readOnly in the schema, render the display variant; everything else renders inputs.
  • The writeable variant adds add and remove buttons: an optional object starts absent, the add button seeds it with the box's default values, and remove clears it back to null.
  • Nothing renders when object.target is missing, or when the target field has no properties in the field schema.
caution

The children must exist in the target's properties, not in the parent's field list. A property that the backend does not expose on the nested object is silently skipped.

See also​