Skip to main content

CnChipsFieldWidget

A list of short strings in one array field of the CURRENT object, drawn as chips and added and removed in place. Registered under the chips-field widget type.

A portal's "Zonder goedkeuring voor deze e-maildomeinen", "Mag ingesloten worden op" and "Talen" are this shape. Every add and remove is ONE PATCH of that field with the full new list.

Content shape​

{
"id": "portal-domains-auto",
"type": "chips-field",
"title": "Zonder goedkeuring",
"content": {
"field": "autoApproveDomains",
"label": "Zonder goedkeuring voor deze e-maildomeinen",
"addLabel": "Domein",
"confirmLabel": "Toevoegen",
"lowercase": true,
"pattern": "^[a-z0-9-]+(\\.[a-z0-9-]+)+$",
"patternMessage": "Dit is geen domeinnaam."
}
}
KeyMeaning
fieldThe array-of-strings field (required): a top-level name or a dot-path such as authentication.registration.allowedDomains. A nested path is written by re-reading the enclosing top-level object, merging the leaf in and PATCHing that object.
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.
label, hint, placeholderTexts, translated through cnTranslate.
addLabel, confirmLabel, removeLabelThe "+ add" chip text, the add button text (default "Add") and the remove button's name (default "Remove").
pattern, patternMessageChecked on every typed entry before any request.
lowercaseStores entries in lower case.
options[{ value, label }]: the add chip offers the options not yet stored instead of free text; chips show the label. Use it for languages.
minItems, required, minItemsMessageThe fewest entries the list may hold (required: true means 1). Removing the last allowed entry is refused with the message (default Keep at least {count}., translated) and nothing is sent.
readOnlyNo add chip, no remove buttons.

Behaviour​

  • An entry is trimmed, then refused with a message before any request when it is empty, fails the pattern or is already in the list.
  • A refused PATCH shows the server's own words and keeps the chips as stored.

Props​

PropTypeDefaultDescription
contentobject{}The configuration above.
modelValuestring[]undefinedForm mode: the list a parent holds. The widget then writes nothing and emits update:modelValue; this is how a settings-form field of type chips takes part in the form's one Save.
objectDataobjectnullThe current detail-page object; the list is read from objectData[field].
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, with the list as the server returned it.

Notes​

  • Content-only on the detail page: it gets the titled card; inside a sections widget it renders bare.
  • For a list of OBJECTS drawn as rows, use field-list.
  • Renderer only: no config form.