CnAdvancedFormDialog
Create/edit dialog with a properties table (click-to-edit), Data (JSON) tab with CodeMirror, and optional Metadata tab. Suited for power users and complex objects. When item is null the dialog runs in create mode; when item is provided it runs in edit mode.
Try it
Wraps: NcDialog, NcButton, NcNoteCard, NcLoadingIcon, NcTextField, NcCheckboxRadioSwitch, CodeMirror (vue-codemirror6)
Use CnAdvancedFormDialog when you need:
- Inline editing of object properties in a table (click row → edit value)
- Raw JSON view and editing with validation
- Metadata display (id, created, updated) in edit mode
Use CnFormDialog when you need a simpler form with auto-generated fields and standard widgets (text, select, checkbox, etc.) without the table/JSON tabs. CnFormDialog also has native json and code widgets (backed by CnJsonViewer) for single-field JSON/code editing — reach for those before CnAdvancedFormDialog when the richer properties table and metadata tab aren't needed.
Overview
CnAdvancedFormDialog provides:
- Properties tab — Table of all schema properties (and existing object keys). Click a row to edit the value inline. Supports
string,number,integer,booleanwith appropriate inputs; other types are read-only and shown as formatted/JSON. Rows can show validation state (valid/invalid/new/warning) whenvalidationDisplay="indicator". - Metadata tab — Read-only display of ID, Created, Updated (from
@selforid/ item). Shown by default only in edit mode; controllable viashowMetadataTab. - Data tab — Full JSON editor (CodeMirror) synced with the form data. Invalid JSON blocks confirm. "Format JSON" button prettifies the content.
The dialog uses the same two-phase pattern as other CRUD dialogs: after the user confirms, @confirm is emitted with the payload. The parent performs the API call and calls setResult({ success: true }) or setResult({ error: 'Message' }) to show the result phase and optional auto-close.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
schema | Object | null | JSON Schema used to derive property list, types, and labels (e.g. schema.properties, schema.required, schema.title) |
item | Object | null | Existing object for edit mode; null for create mode |
initialValues | Object | null | Field values seeded into a create form on open, layered over the schema defaults. Unlike item this does not flip the dialog into edit mode, so it is the right seam for fixing a discriminator or parent key the user should not have to type (e.g. { ticketType: 'request' }). Ignored when item is set. |
dialogTitle | String | '' | Override dialog title; default is "Create {schemaTitle}" or "Edit {schemaTitle}" |
nameField | String | 'title' | Property used as display name (e.g. in breadcrumbs or other UI) |
successText | String | '' | Message shown in result phase on success; default "{schemaTitle} saved successfully." |
cancelLabel | String | 'Cancel' | Label for cancel button in form phase |
closeLabel | String | 'Close' | Label for close button in result phase |
confirmLabel | String | '' | Label for primary action; default "Create" (create) or "Save" (edit) |
excludeFields | Array | [] | Property keys to hide from the properties table and from generated fields |
includeFields | Array | null | If set, only these property keys are shown (whitelist) |
fieldOverrides | Object | {} | Per-property overrides passed to fieldsFromSchema (e.g. label, widget hints) |
showPropertiesTable | Boolean | true | Show the Properties tab |
showJsonTab | Boolean | true | Show the Data (JSON) tab |
showMetadataTab | Boolean | null | Force show/hide Metadata tab; null = show only when item is set (edit mode) |
editablePropertyTypes | Array | null | Schema types that are editable in the table; default ['string','number','integer','boolean','array','object'] |
validationDisplay | String | 'indicator' | 'indicator' = show validation state on rows (valid/invalid/new/warning); 'none' = no indicator |
jsonEditorDark | Boolean | false | Use dark theme for the CodeMirror JSON editor |
Events
| Event | Payload | Description |
|---|---|---|
confirm | formData | Emitted when the user confirms. Payload is the current form data (may include id in edit mode). Parent is responsible for performing the save and calling setResult(). |
close |