From 79cdf5e65e9a3c1d0ffd648b6315583687205bf0 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 28 Jul 2022 16:11:20 +0200 Subject: [PATCH] Change sales form 'Interested in' to be multi-select checkboxes (#8872) * Change form helper serialization to allow for multi-values * Change sales form 'Interested in' to be multi-select checkboxes * Add clarification text to server pro/commons products GitOrigin-RevId: 2732a8975ea36602375949a23b19705e4d4c9080 --- .../web/frontend/js/features/form-helpers/hydrate-form.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/form-helpers/hydrate-form.js b/services/web/frontend/js/features/form-helpers/hydrate-form.js index 2eb6907e3b..555e156f77 100644 --- a/services/web/frontend/js/features/form-helpers/hydrate-form.js +++ b/services/web/frontend/js/features/form-helpers/hydrate-form.js @@ -109,7 +109,13 @@ async function sendFormRequest(formEl, captchaResponse) { if (captchaResponse) { formData.set('g-recaptcha-response', captchaResponse) } - const body = Object.fromEntries(formData.entries()) + const body = Object.fromEntries( + Array.from(formData.keys(), key => { + // forms may have multiple keys with the same name, eg: checkboxes + const val = formData.getAll(key) + return [key, val.length > 1 ? val : val.pop()] + }) + ) const url = formEl.getAttribute('action') return postJSON(url, { body }) }