From a638bf3aead4c62fdcd87142a6c0450849dff8c7 Mon Sep 17 00:00:00 2001 From: Steven Bal Date: Mon, 11 Nov 2024 12:46:26 +0100 Subject: [PATCH] :bug: [open-formulieren/open-forms#4772] Set select dataType to string because Select components did not have a dataType set, formio tries to cast it to other types if possible, which causes issues when submitting the data to the backend. For that reason we set the value to string to avoid this unwanted normalization --- src/formio/components/select.ts | 4 ++++ test-d/formio/components/select.test-d.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/formio/components/select.ts b/src/formio/components/select.ts index 18a0314..e34f513 100644 --- a/src/formio/components/select.ts +++ b/src/formio/components/select.ts @@ -26,6 +26,10 @@ interface BaseSelectSchema { // dynamic values into data.values already. // So our openForms.dataSrc == itemsExpression results in dataSrc == values. dataSrc: 'values'; + // Fix for https://github.com/open-formulieren/open-forms/issues/4772 + // ensure the datatype is set to string to avoid formio casting it to other + // types (such as integer) + dataType: 'string'; } /** diff --git a/test-d/formio/components/select.test-d.ts b/test-d/formio/components/select.test-d.ts index 6802564..94d01ab 100644 --- a/test-d/formio/components/select.test-d.ts +++ b/test-d/formio/components/select.test-d.ts @@ -7,6 +7,7 @@ expectAssignable({ id: 'yejak', type: 'select', dataSrc: 'values', + dataType: 'string', key: 'someSelect', label: 'Some select', openForms: { @@ -28,6 +29,7 @@ expectAssignable({ id: 'yejak', type: 'select', dataSrc: 'values', + dataType: 'string', key: 'someSelect', label: 'Some select', openForms: { @@ -42,6 +44,7 @@ expectAssignable({ id: 'yejak', type: 'select', dataSrc: 'values', + dataType: 'string', key: 'someSelect', label: 'Some select', multiple: false, @@ -58,6 +61,7 @@ expectAssignable({ id: 'yejak', type: 'select', dataSrc: 'values', + dataType: 'string', key: 'someSelect', label: 'Some select', multiple: true, @@ -74,6 +78,7 @@ expectAssignable({ id: 'yejak', type: 'select', dataSrc: 'values', + dataType: 'string', key: 'someSelect', label: 'Some select', multiple: true, @@ -90,6 +95,7 @@ expectAssignable({ id: 'yejak', type: 'select', dataSrc: 'values', + dataType: 'string', key: 'someSelect', label: 'Some select', defaultValue: 'dummy', @@ -122,6 +128,7 @@ expectAssignable({ id: 'yejak', type: 'select', dataSrc: 'values', + dataType: 'string', // basic tab label: 'Some select', key: 'someSelect',