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
This commit is contained in:
Thomas 2022-07-28 16:11:20 +02:00 committed by Copybot
parent 8841c8c874
commit 79cdf5e65e

View file

@ -109,7 +109,13 @@ async function sendFormRequest(formEl, captchaResponse) {
if (captchaResponse) { if (captchaResponse) {
formData.set('g-recaptcha-response', 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') const url = formEl.getAttribute('action')
return postJSON(url, { body }) return postJSON(url, { body })
} }