Ga naar hoofdinhoud

CnSettingsField

One settings field: the control for its type with its label, and under it an error or a hint, tied to the control. CnSettingsPage renders its fields with it, and CnSettingsFieldsSection builds on it.

<CnSettingsField
:field="{ key: 'apiKey', label: 'API key', type: 'secret', secretSet: true }"
v-model="form.apiKey"
hint="Never shown again." />
TypeControl
text (default), stringNcTextField
passwordNcTextField, masked, showing its value back
date, datetime-local (also datetime, date-time), email, urlNcTextField of that input type; the value stays the text the input holds
week-hoursA fieldset named by the label with one row per day (days, default Monday to Sunday, named in the user's language): an Open switch and, while open, an opening and a closing time. The value is { <day>: { opens, closes } | null }; an opened day starts at defaultOpens/defaultCloses (08:00 to 17:00)
secretNcTextField, masked and replace-only; with secretSet it says a value is stored. With clearable and a stored value, a switch (clearLabel, default "Remove the stored value") emits clear; the host passes clearing and the input is disabled while it is on
numberNcTextField of type number (min, max)
textareaNcTextArea (rows)
booleanNcCheckboxRadioSwitch as a checkbox
switchNcCheckboxRadioSwitch as a switch
select, enumNcSelect with inputLabel; static options, or optionsUrl with optionsPath, optionLabel, optionValue and optionDetail (a value in brackets after the label)
radioA fieldset named by the label with one NcCheckboxRadioSwitch radio per option; an option's description is a line under it
linesNcTextArea, one entry per line (the host turns the list into lines and back)
checkboxesA fieldset named by the label with one NcCheckboxRadioSwitch checkbox per option; the value is the list of checked values in option order. A select with multiple: true is an NcSelect that takes several values, the value again a list
pairsA fieldset named by the label with one row per { key, value } entry of the value: a key input (keyLabel, keyMaxLength), a value input (valueLabel, valueType: 'number') and a remove button named after the key; an add button (addLabel) under the rows. With valueSource: { register, schema, labelField?, valueField?, limit? } the value is an NcSelect over those OpenRegister objects (value the object id, label labelField); when the register holds more than it read (default 1000), a line says only the first ones are listed
headingThe label as a subheading; holds no value
statusA read-only NcNoteCard with the host's text in its tone; holds no value
actionA button with the label, emitting action; the host passes actionBusy and actionResult ({ type, text }, drawn as a note under it). With href (and target) it is a link to that page instead and emits nothing
imageA preview tile (the image at the value's url, else initials) and a button that uploads a file to uploadUrl at once (uploadField, uploadParams, uploadValuePath, previewUrl), emitting uploaded hideLabel: true keeps the field's label for a screen reader only.

Props​

PropTypeDefaultDescription
fieldObjectrequiredThe field: { key, label, type?, options?, optionsUrl?, optionsPath?, optionLabel?, optionValue?, placeholder?, rows?, min?, max?, required?, readOnly?, secretSet? }. The label arrives translated.
modelValueanynullThe value.
errorString''A validation message under the control.
hintString''A hint under the control, not drawn while there is an error.

Events​

EventPayloadDescription
update:modelValuevalueThe value changed.
uploadedstringAn image was uploaded; the payload is its new url.
clearbooleanA clearable secret's removal switch changed.
actionnoneAn action field's button was pressed.