diff --git a/packages/nc-gui/components/smartsheet/column/ButtonOptions.vue b/packages/nc-gui/components/smartsheet/column/ButtonOptions.vue index ce76a57b03..e1145eea71 100644 --- a/packages/nc-gui/components/smartsheet/column/ButtonOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/ButtonOptions.vue @@ -26,7 +26,8 @@ const vModel = useVModel(props, 'value', emit) const meta = inject(MetaInj, ref()) -const { isEdit, setAdditionalValidations, validateInfos, sqlUi, column, isWebhookCreateModalOpen } = useColumnCreateStoreOrThrow() +const { isEdit, setAdditionalValidations, validateInfos, sqlUi, column, isWebhookCreateModalOpen, validate } = + useColumnCreateStoreOrThrow() const uiTypesNotSupportedInFormulas = [UITypes.QrCode, UITypes.Barcode, UITypes.Button] @@ -77,7 +78,7 @@ const validators = { validator: (_: any, formula: any) => { return (async () => { if (vModel.value.type === 'url') { - if (!formula?.trim()) throw new Error('Required') + if (!formula?.trim()) throw new Error('Formula is required for URL Button') try { await validateFormulaAndExtractTreeWithType({ @@ -191,6 +192,8 @@ if ((column.value?.colOptions as any)?.formula_raw) { meta?.value?.columns as ColumnType[], (column.value?.colOptions as any)?.formula_raw, ) || '' +} else { + vModel.value.formula_raw = '' } const colorClass = { diff --git a/packages/nocodb/src/models/Column.ts b/packages/nocodb/src/models/Column.ts index f329ffbd4c..ea558d8046 100644 --- a/packages/nocodb/src/models/Column.ts +++ b/packages/nocodb/src/models/Column.ts @@ -503,6 +503,19 @@ export default class Column implements ColumnType { break; case UITypes.Button: res = await ButtonColumn.read(context, this.id, ncMeta); + + // add default values if options are missing + if (!res) { + res = { + type: 'url', + theme: 'solid', + color: 'brand', + label: 'Button', + error: 'Invalid configuration', + formula_raw: '', + }; + } + break; case UITypes.QrCode: res = await QrCodeColumn.read(context, this.id, ncMeta);