Skip to content

Beautiful Open-Source Form Builder

Refactor type checks in form components to ensure string validation

Julien Nahum340368cd9dbf
diff --git a/client/components/open/forms/components/FormFieldsEditor.vue b/client/components/open/forms/components/FormFieldsEditor.vue
index 9fd1af05b..abe9d219e 100644
--- a/client/components/open/forms/components/FormFieldsEditor.vue
+++ b/client/components/open/forms/components/FormFieldsEditor.vue
@@ -47,6 +47,7 @@
class="group flex items-center gap-x-0.5 py-1.5 pr-1"
>
<BlockTypeIcon
+ v-if="element.type && typeof element.type === 'string'"
:type="element.type"
class="ml-2"
/>
@@ -87,7 +88,7 @@
</button>
</UTooltip>
<UTooltip
- v-if="!element.type.startsWith('nf-')"
+ v-if="element.type && typeof element.type === 'string' && !element.type.startsWith('nf-')"
:text="element.required ? 'Make it optional' : 'Make it required'"
arrow
>
diff --git a/client/components/open/forms/components/form-logic-components/ConditionEditor.client.vue b/client/components/open/forms/components/form-logic-components/ConditionEditor.client.vue
index e6a043e51..94cb92a24 100644
--- a/client/components/open/forms/components/form-logic-components/ConditionEditor.client.vue
+++ b/client/components/open/forms/components/form-logic-components/ConditionEditor.client.vue
@@ -51,7 +51,7 @@ export default {
rules() {
return this.form.properties
.filter((property) => {
- return !property.type.startsWith("nf-")
+ return property.type && typeof property.type === 'string' && !property.type.startsWith("nf-")
})
.map((property) => {
const workspaceId = this.form.workspace_id
diff --git a/client/components/open/forms/fields/FormFieldEdit.vue b/client/components/open/forms/fields/FormFieldEdit.vue
index 0d04fb2c1..d782f4fbc 100644
--- a/client/components/open/forms/fields/FormFieldEdit.vue
+++ b/client/components/open/forms/fields/FormFieldEdit.vue
@@ -128,7 +128,7 @@ onMounted(() => {
})
const isBlockField = computed(() => {
- return field.value && field.value.type.startsWith('nf')
+ return field.value && field.value.type && typeof field.value.type === 'string' && field.value.type.startsWith('nf')
})
const typeCanBeChanged = computed(() => {
diff --git a/client/composables/components/tables/useTableState.js b/client/composables/components/tables/useTableState.js
index 8f7a6bfc8..f66e3494b 100644
--- a/client/composables/components/tables/useTableState.js
+++ b/client/composables/components/tables/useTableState.js
@@ -24,7 +24,7 @@ export function useTableState(form, withActions = false) {
const baseColumns = form.value.properties
.filter((field) => {
- return !field.type.startsWith('nf-')
+ return field.type && typeof field.type === 'string' && !field.type.startsWith('nf-')
})
.map(col => {
const { columns: matrixColumns, ...rest } = col