Skip to main content

CnSubObjectsField

Edits an array of objects embedded in one object as a table. CnFormDialog renders it for a property of type: array whose items is an object schema, when the property declares x-widget: sub-objects or the form passes fieldOverrides.<key>.widget: 'sub-objects'. Without either, the property keeps its current widget.

Columns come from items.properties, up to maxColumns; the other properties stay editable in the row dialog. Each row has Edit (opens a nested CnFormDialog over items, so every widget works inside a row), Duplicate, Move up, Move down and Remove. Move up and Move down are buttons, so the order can be changed from the keyboard. When items.properties declares order, it is rewritten to 1..n after every change. In CnFormDialog, Save is blocked when a row misses a value listed in items.required, and the message names the row ("Row 2: key is required.").

For rows that are their own records, use an object-list widget instead.

Usage​

<CnSubObjectsField v-model="statuses" input-label="Statuses" :items="itemsSchema" />

Props​

PropTypeDefaultDescription
modelValueArray[]The array of row objects (v-model).
itemsObject{ properties: {} }JSON Schema of one row (type: object, properties, optional required).
inputLabelString''Visible label of the table.
maxColumnsNumber6Most columns shown in the table; further properties are edited in the row dialog.
disabledBooleanfalseHide the editing controls.
errorString''Validation message shown under the table.
addLabelString'Add row'Label of the add button.
fieldOverridesObject{}Field overrides forwarded to the row dialog.

Events​

EventPayloadDescription
update:modelValueobject[]The rows in their new sequence.