diff --git a/apps/web/modules/event-types/components/tabs/advanced/FormBuilder.tsx b/apps/web/modules/event-types/components/tabs/advanced/FormBuilder.tsx
index 1b86a8f06f..ae5b3fe047 100644
--- a/apps/web/modules/event-types/components/tabs/advanced/FormBuilder.tsx
+++ b/apps/web/modules/event-types/components/tabs/advanced/FormBuilder.tsx
@@ -70,6 +70,23 @@ const getLocationFieldType = (field: RhfFormField) => {
return baseFieldType;
};
+function isWhitespaceOnly(val: unknown): boolean {
+ return typeof val === "string" && val.length > 0 && val.trim().length === 0;
+}
+
+function hasWhitespaceOnlyLabel(data: RhfFormField): boolean {
+ if (isWhitespaceOnly(data.label)) return true;
+ const variants = data.variantsConfig?.variants;
+ if (!variants) return false;
+ for (const variant of Object.values(variants)) {
+ const fields = variant?.fields ?? [];
+ for (const f of fields) {
+ if (isWhitespaceOnly(f?.label)) return true;
+ }
+ }
+ return false;
+}
+
/**
* It works with a react-hook-form only.
* `formProp` specifies the name of the property in the react-hook-form that has the fields. This is where fields would be updated.
@@ -387,6 +404,11 @@ export const FormBuilder = function FormBuilder({
const type = data.type || "text";
const isNewField = !fieldDialog.data;
+ if (hasWhitespaceOnlyLabel(data)) {
+ showToast(t("label_cannot_be_whitespace"), "error");
+ return;
+ }
+
if (data.name === "guests" && type !== "multiemail") {
showToast(t("guests_field_must_be_multiemail"), "error");
return;
@@ -900,12 +922,12 @@ function FieldLabel({ field }: { field: RhfFormField }) {
);
} else {
- return {field.label || t(field.defaultLabel || "")};
+ return {field.label?.trim() || t(field.defaultLabel || "")};
}
}
const variant = field.variant || defaultVariant;
diff --git a/packages/i18n/locales/en/common.json b/packages/i18n/locales/en/common.json
index d8c92ddbdc..ef962e5377 100644
--- a/packages/i18n/locales/en/common.json
+++ b/packages/i18n/locales/en/common.json
@@ -1231,6 +1231,7 @@
"additional_inputs": "Additional inputs",
"additional_input_description": "Require scheduler to input additional inputs prior the booking is confirmed",
"label": "Label",
+ "label_cannot_be_whitespace": "Label cannot be only whitespace",
"placeholder": "Placeholder",
"display_add_to_calendar_organizer": "Use \"Add to calendar\" email as the organizer",
"display_email_as_organizer": "We'll display this email address as the organizer, and send confirmation emails here.",