CnSwitchRowsWidget
A card of switches, each with a label and a hint, bound to boolean fields of the CURRENT object. A toggle saves at once. Registered under the switch-rows widget type.
A portal's "Verkeer meten", "Berichtenbox van MijnOverheid" and "Als app installeren", and a settings card of "Verplichte velden" are this shape.
Content shape
{
"id": "portal-install",
"type": "switch-rows",
"title": "Als app installeren",
"content": {
"rows": [
{ "key": "installEnabled", "label": "Bezoekers kunnen de portal installeren op hun telefoon", "hint": "De app bewaart alleen de schil van de site." }
]
}
}
| Key | Meaning |
|---|---|
rows[].key | A boolean field of the object: a top-level name or a dot-path (written by re-reading the enclosing top-level object and merging the leaf in). |
save | { url, method?, payload? }: write through an app endpoint instead of the object. url and payload are templates with the tokens {value} (the changed value), {field} (its path), {changes} (the changed values as a nested object) and {object.<path>} (a field of the current object). method is PUT, POST or PATCH (default PATCH); payload defaults to {changes}. A string that is exactly one token keeps the value's type. The stored value is still read from the object by path. |
rows[].label, rows[].hint | Texts, translated through cnTranslate. |
rows[].invert | The switch is on when the field is false (a stored installDisabled read as "on"). |
readOnly | Disables every switch. |
Behaviour
- A toggle sends ONE
PATCHof that field. The switch is disabled while the request runs. - A refused PATCH puts the switch back to its last saved state and shows the server's own words.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
content | object | {} | The configuration above. |
objectData | object | null | The current detail-page object; switches are read from it. |
objectId | string|number | '' | The object id, for the PATCH url. |
register | string|object | '' | Register slug of the surface, for the PATCH url. |
schema | string|object | '' | Schema slug of the surface, for the PATCH url. |
Events
| Event | Payload | Description |
|---|---|---|
saved | { field, value } | After a successful PATCH of one switch. |
Notes
- Content-only on the detail page: it gets the titled card; inside a
sectionswidget it renders bare. - Renderer only: no config form.