diff --git a/src/DonationForms/resources/app/utilities/convertValuesToFormData.ts b/src/DonationForms/resources/app/utilities/convertValuesToFormData.ts index 794b53874e..93e5614a4d 100644 --- a/src/DonationForms/resources/app/utilities/convertValuesToFormData.ts +++ b/src/DonationForms/resources/app/utilities/convertValuesToFormData.ts @@ -3,9 +3,16 @@ */ export default function convertValuesToFormData(values: object): FormData { const formData = new FormData(); + for (const valueKey in values) { + const value = values[valueKey]; - for (const key in values) { - formData.append(key, values[key]); + if (value !== null && typeof value === 'object') { + for (const objKey in value) { + formData.append(`${valueKey}[${objKey}]`, value[objKey]); + } + } else { + formData.append(valueKey, value); + } } return formData;