xini / silverstripe-mailchimp-signup

Adds page type for a MailChimp signup form. Form fields are read automatically from the MailChimp list.
BSD 3-Clause "New" or "Revised" License
4 stars 6 forks source link

Can't submit MailChimpSignupPage form with "Birthday" type fields #10

Closed GuySartorelli closed 3 years ago

GuySartorelli commented 3 years ago

If a mailchimp audience has a field of the type "Birthday", the form submission gets a 400 error response: "Your merge fields were invalid".

This seems to be because of the format of the value being sent to mailchimp - birthday fields can only have a day and a month, but the datefield sends a year as well. Adding the following line into SignupControllerExtension::doSubscription to debug the issue shows that changing the format of the submitted value does allow the form to submit.

$mergeVars['BIRTHDAY'] = DBField::create_field('Date', $data['BIRTHDAY'])->Format('MM/dd');

I don't know whether it would be necessary to adjust the front-end field so a year can't be submitted, but this issue is just to resolve the error on submission.

xini commented 3 years ago

Thanks for this. I'll have a look into it asap.