Ga naar hoofdinhoud

CnResourceSelect

An OpenRegister object picker that can create a new object from the typed search term.

It searches a register + schema for objects whose label matches what the user types and renders them as options. When the typed term matches no existing object, a synthetic "Create '<term>'" option appears at the bottom of the list; choosing it persists a new object (via useObjectStore().saveObject, writing the term to labelField) and selects it — so a user who can't find a record never hits a dead "no results" path, they just type the name and make one inline.

This closes the gap where a plain NcSelect against OpenRegister offers no way to create a missing option (e.g. an agent logging a call for a client that isn't in the system yet).

Usage

<CnResourceSelect
register="pipelinq"
schema="client"
label-field="name"
:model-value="clientId"
:input-label="t('pipelinq', 'Client')"
@update:modelValue="clientId = $event"
@create="onClientCreated" />

Props

PropTypeDefaultDescription
registerString— (required)OpenRegister register slug to search/create in.
schemaString— (required)OpenRegister schema slug to search/create in.
modelValueString | Number''Currently-selected object id (v-model).
labelFieldString'name'Object field used as the option label AND written on create.
inputLabelString''Accessible input label for the underlying NcSelect.
inputIdString''DOM id for the input (a11y association).
clearableBooleantrueWhether the selection can be cleared.
minCharsNumber2Minimum characters before searching / offering create.
allowCreateBooleantrueOffer the inline "Create '<term>'" option when the search yields no exact match. Off → behaves like a plain async object select.
createDefaultsObject{}Extra fields merged into the payload when creating a new object (e.g. a fixed type). labelField is always set to the term.

Events

EventPayloadDescription
update:modelValuestringThe selected (or newly-created) object id.
createobjectEmitted with the freshly-created OpenRegister object when the user chose "Create '<term>'".