From d8f1b7960e7e077c3f78b846743f2226a8425a91 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Mon, 9 Oct 2023 08:22:19 +0100 Subject: [PATCH] Fix form block crash on no data tables (#11995) * Fix form block crash on no data tables * Refactor * Refactor --- packages/builder/src/builderStore/dataBinding.js | 7 +++++-- .../controls/FieldConfiguration/FieldConfiguration.svelte | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index 386b47105d..8445bf9e6d 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -948,12 +948,15 @@ export const buildFormSchema = (component, asset) => { if (component._component.endsWith("formblock")) { let schema = {} - const datasource = getDatasourceForProvider(asset, component) const info = getSchemaForDatasource(component, datasource) + if (!info?.schema) { + return schema + } + if (!component.fields) { - Object.values(info?.schema) + Object.values(info.schema) .filter( ({ autocolumn, name }) => !autocolumn && !["_rev", "_id"].includes(name) diff --git a/packages/builder/src/components/design/settings/controls/FieldConfiguration/FieldConfiguration.svelte b/packages/builder/src/components/design/settings/controls/FieldConfiguration/FieldConfiguration.svelte index 4c4fa0b7b7..4169cb7d3d 100644 --- a/packages/builder/src/components/design/settings/controls/FieldConfiguration/FieldConfiguration.svelte +++ b/packages/builder/src/components/design/settings/controls/FieldConfiguration/FieldConfiguration.svelte @@ -37,7 +37,7 @@ } $: datasource = getDatasourceForProvider($currentAsset, componentInstance) - $: resourceId = datasource.resourceId || datasource.tableId + $: resourceId = datasource?.resourceId || datasource?.tableId $: if (!isEqual(value, cachedValue)) { cachedValue = cloneDeep(value)