From 20b3efbcb62da216289f2d943cf4be6a0bd0a81f Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Wed, 22 Mar 2023 00:14:18 +0530 Subject: [PATCH] Handle empty label from Custom inputs (#7871) * Handle empty label from Custom inputs * Fix comment --- packages/features/bookings/lib/getBookingFields.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/features/bookings/lib/getBookingFields.ts b/packages/features/bookings/lib/getBookingFields.ts index 42304c9ad7..9bfd75e6dc 100644 --- a/packages/features/bookings/lib/getBookingFields.ts +++ b/packages/features/bookings/lib/getBookingFields.ts @@ -295,12 +295,13 @@ export const ensureBookingInputsHaveSystemFields = ({ // Backward Compatibility: If we are migrating from old system, we need to map `customInputs` to `bookingFields` if (handleMigration) { - customInputs.forEach((input) => { + customInputs.forEach((input, index) => { bookingFields.push({ label: input.label, editable: "user", // Custom Input's slugified label was being used as query param for prefilling. So, make that the name of the field - name: slugify(input.label), + // Also Custom Input's label could have been empty string as well. But it's not possible to have empty name. So generate a name automatically. + name: slugify(input.label || `${input.type}-${index + 1}`), placeholder: input.placeholder, type: CustomInputTypeToFieldType[input.type], required: input.required,