Skip to main content

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." }
]
}
}
KeyMeaning
rows[].keyA 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[].hintTexts, translated through cnTranslate.
rows[].invertThe switch is on when the field is false (a stored installDisabled read as "on").
readOnlyDisables every switch.

Behaviour​

  • A toggle sends ONE PATCH of 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​

PropTypeDefaultDescription
contentobject{}The configuration above.
objectDataobjectnullThe current detail-page object; switches are read from it.
objectIdstring|number''The object id, for the PATCH url.
registerstring|object''Register slug of the surface, for the PATCH url.
schemastring|object''Schema slug of the surface, for the PATCH url.

Events​

EventPayloadDescription
saved{ field, value }After a successful PATCH of one switch.

Notes​

  • Content-only on the detail page: it gets the titled card; inside a sections widget it renders bare.
  • Renderer only: no config form.