Skip to content

Scheduling infrastructure for absolutely everyone.

make "text" the default value (#7543)

Carina Wollendorfera0f55707e2d4
diff --git a/packages/features/form-builder/FormBuilder.tsx b/packages/features/form-builder/FormBuilder.tsx
index 86ebc33b6ed..aa308df96e6 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 (
<div>
@@ -374,6 +374,7 @@ export const FormBuilder = function FormBuilder({
<Form
form={fieldForm}
handleSubmit={(data) => {
+ 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({
});
}}>
<SelectField
- required
+ defaultValue={FieldTypes[3]} // "text" as defaultValue
isDisabled={
fieldForm.getValues("editable") === "system" ||
fieldForm.getValues("editable") === "system-but-optional"
@@ -543,7 +545,7 @@ export const ComponentForField = ({
};
readOnly: boolean;
} & ValueProps) => {
- const fieldType = field.type;
+ const fieldType = field.type || "text";
const componentConfig = Components[fieldType];
const isValueOfPropsType = (val: unknown, propsType: typeof componentConfig.propsType) => {