From a0f55707e2d48cfaa1173a29ad9898a0bb6ec4ca Mon Sep 17 00:00:00 2001 From: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Date: Mon, 6 Mar 2023 18:27:29 -0500 Subject: [PATCH] make "text" the default value (#7543) Co-authored-by: CarinaWolli --- packages/features/form-builder/FormBuilder.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/features/form-builder/FormBuilder.tsx b/packages/features/form-builder/FormBuilder.tsx index 86ebc33b6e..aa308df96e 100644 --- a/packages/features/form-builder/FormBuilder.tsx +++ b/packages/features/form-builder/FormBuilder.tsx @@ -255,7 +255,7 @@ export const FormBuilder = function FormBuilder({ remove(index); }; - const fieldType = FieldTypesMap[fieldForm.watch("type")]; + const fieldType = FieldTypesMap[fieldForm.watch("type") || "text"]; const isFieldEditMode = fieldDialog.fieldIndex !== -1; return (
@@ -374,6 +374,7 @@ export const FormBuilder = function FormBuilder({
{ + const type = data.type || "text"; const isNewField = fieldDialog.fieldIndex == -1; if (isNewField && fields.some((f) => f.name === data.name)) { showToast(t("form_builder_field_already_exists"), "error"); @@ -384,6 +385,7 @@ export const FormBuilder = function FormBuilder({ } else { const field: RhfFormField = { ...data, + type, sources: [ { label: "User", @@ -402,7 +404,7 @@ export const FormBuilder = function FormBuilder({ }); }}> { - const fieldType = field.type; + const fieldType = field.type || "text"; const componentConfig = Components[fieldType]; const isValueOfPropsType = (val: unknown, propsType: typeof componentConfig.propsType) => {