Skip to main content

Box reference

Every box class, and the parameters each one adds on top of the common ones.

Boxes are the layout of a create, edit or show view — see Form schema generators for how they are composed. This page is the list to check a parameter against.

Declaration​

from habarico.schema import Box, GridBox, GridItemBox, ListBox, TabBox, TabItemBox
from habarico.schema.generators import EditViewSchemaGenerator

EditViewSchemaGenerator(box=TabBox(boxes=[
TabItemBox(label="Product", boxes=[
GridBox(boxes=[
GridItemBox(md=8, boxes=[Box(label="Basics", boxes=["name", "sku"])]),
GridItemBox(md=4, boxes=[Box(label="Pricing", boxes=["price", "vat_rate"])]),
]),
]),
TabItemBox(label="Orders", boxes=[ListBox(reference="eshop/order", target="product")]),
]))

All classes import from habarico.schema (or habarico.schema.boxes).

The classes​

ClasstypeRenders as
BoxsimpleA labelled stack of fields — the fallback
GridBoxgridA responsive 12-column grid
GridItemBoxgrid-itemOne column of a grid
GridFieldsBoxgridA grid with one field per column — a shorthand
TabBoxtabTabs
WizardBoxwizardA stepped form
TabItemBoxtab-itemOne tab or one wizard step
ListBoxlistAn embedded list of a related resource
GalleryBoxgalleryAn image carousel from a related resource
ObjectBoxobjectThe properties of a nested serializer
ArrayBoxarrayA repeatable group of fields

Common parameters​

Accepted by every class (they come from BaseBox):

ParameterTypeDefaultDescription
namestrthe box's indexIdentifies the box; tab and wizard state is keyed by it
labelstrNoneSection heading; on its own it turns the card frame on
cardboolNoneCard frame: True always, False never (even with a label), None leaves it to the frontend — see below
collapsible'open' | 'closed'NoneMakes the box collapsible; the value is the initial state
boxeslist[BaseBox | str | Field]NoneChildren: nested boxes, field names, or Field descriptors
read_onlyboolFalseRenders every field inside as a display field
show_querystrNoneCondition expression; the box disappears when it is falsy
required_querystrNoneCondition expression; the box's fields become required when it is truthy
toolbar_actionsActionsNoneButtons in the box header
bottom_actionsActionsNoneButtons below the box's fields

show_query and required_query are stored under options.dynamic_render.

Left at None, card is decided by the frontend: a box takes the card when it has a label, toolbar actions or is collapsible, and the view's first box takes it on a page surface — inside a dialog or a side panel the overlay is already the card. A first box that only wraps other boxes (Box without fields, GridBox, TabBox, WizardBox) hands that default to its children, so the card lands on the first box holding fields. Pass card=False to keep a labelled box card-less; its label then renders as a plain section heading.

TabBox and WizardBox​

ParameterTypeTabBox defaultWizardBox default
show_toolbar_navigationboolFalseTrue
validate_stepsbool—True

The children should be TabItemBox — its label is required, and it becomes the tab caption or step caption. In the schema these land under a tab / wizard object:

{"type": "wizard", "wizard": {"show_toolbar_navigation": true, "validate_steps": true}}

GridItemBox​

ParameterTypeDefaultDescription
xs, sm, md, lg, xlintNoneColumn span (1–12) at that breakpoint

Omitting them all lets the frontend compute the spans from the number of children. Mixing explicit and computed items in one grid does not work — one GridItemBox switches the whole grid to explicit mode.

GridFieldsBox​

A shorthand for "one field per grid column": it takes the fields positionally and wraps each in its own Box.

GridFieldsBox("price", "vat_rate", "stock")
caution

It also accepts xs, sm, md, lg and xl, but ignores them — they are neither forwarded to the generated boxes nor to GridBox. Use GridBox with explicit GridItemBox children when the widths matter.

ListBox​

ParameterTypeDefaultDescription
reference (required)str—Resource to list
targetstrNoneForeign key pointing back at the parent record
boxesFieldsetNoneWhich columns the embedded table shows, and in what order
row_actionsActionsNoneButtons in the row action column
list_toolbar_actionsActionsNoneActions in the table's own toolbar, e.g. create
list_actionsActionsNoneUtility actions next to the filter bar (export, print, …)
filtersFiltersNoneFilters offered on the embedded list
default_sortingSortingOrStrNoneInitial sort — a Sorting object, or a Django-style string ("placed_at" ascending, "-placed_at" descending)
extra_filtersdictNoneStatic filters applied on top, invisible to the user
sortable_field_namestrNoneField storing the order; enables drag-and-drop sorting
sortable_sort_for_filtersdictNoneFilters under which reordering is allowed
schema_paramsdict[str, str]NoneExtra params sent when fetching the reference's schema
single_click_actionActionDescriptor | strNoneAction on a single row click; a plain name is normalized into a descriptor
double_click_actionActionDescriptor | strauto: show → edit → nothingAction on a double click
caution

toolbar_actions and list_toolbar_actions are two different slots. toolbar_actions is the common BaseBox parameter: bound to the parent record and rendered in the box header. list_toolbar_actions is bound to the referenced resource and is emitted inside the list parameters, where the frontend renders it in the table's own toolbar. Passing the actions to the wrong one puts them on the wrong record.

GalleryBox​

ParameterTypeDefaultDescription
reference (required)str—Resource holding the images
image_field (required)str—Field containing the image ({url, filename})
targetstrNoneForeign key pointing back at the parent
filtersFiltersNoneFilters offered on the underlying list
default_sortingSortingOrStrNoneInitial sort
extra_filtersdictNoneStatic filters applied on top
schema_paramsdict[str, str]NoneExtra params sent when fetching the reference's schema

A gallery box is always read-only — it passes read_only=True up to BaseBox regardless of what you set. So does ListBox.

ObjectBox​

ParameterTypeDefaultDescription
target (required)str—Name of the nested serializer field

Children are named without the target. prefix; the frontend binds them under it.

ArrayBox​

ParameterTypeDefaultDescription
target (required)str—Name of the nested serializer field holding the array
inlineboolTrue unless a child is a boxRenders items as table-like rows instead of stacked groups
listed_by_field_namestrNoneSwitches to the chip picker; names the item field holding the enum value
listed_by_other_valueslist[str | int]NoneEnum values kept out of the fixed rows and left addable

The inline default is computed: an array whose children are plain fields renders inline, one that contains a nested box does not. Pass it explicitly to override that.

See also​