Interest groups that are shown as radio buttons are not handled correctly in the Mailchimp Subscription entity field, or in the Mailchimp Signup blocks and pages. The selected default radio option is not shown in the entity field settings, and the chosen option is not sent from the entity form nor the signup form. The radio option is stored by Drupal as a string, but the module expects it to be an array.

Issue fork mailchimp-2981031

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Peacog created an issue. See original summary.

peacog’s picture

Here's a patch that fixes the bug.

peacog’s picture

Status: Needs review » Needs work
StatusFileSize
new669 bytes
new3.11 KB

I've updated the patch to handle radio groups on the entity edit form.

More work in needed on this. Right now if you change a radio option the new value is added to the group in mailchimp instead of replacing the original value.

peacog’s picture

Status: Needs work » Needs review
Related issues: +#2981876: Store interest groups as serialized arrays
StatusFileSize
new3.49 KB
new4.64 KB

The previous approach resulted in quite a bit of duplicate code so I have slightly changed the approach and have resolved the problem of multiple values for radio style categories being seen at the mailchimp website.

A few things to note: for radio button categories to work two other patches are required: #2984542: Subscription field values are not saved to the database and #2981876: Store interest groups as serialized arrays. This patch in this issue should be applied before the one in #2984542: Subscription field values are not saved to the database.

samuel.mortenson’s picture

Assigned: Unassigned » rjacobsen0
rjacobsen0’s picture

The previous patch is good, but just slightly off the mark. Possibly the code changed, so the patch needed an update. I fixed it so it will save group information, where the group is presented as radio buttons. Thanks for the good work!

rjacobsen0’s picture

Doing some tests...
1. Create a Mailchimp signup field on /admin/config/people/accounts/fields. Open an incognito browser window and request a new account on your D8 site. You will need to clear cache before you can load your D8 site to do so.
2. Subscribe is not working in this case.

Stopping tests there. Will try to fix, then test more.

rjacobsen0’s picture

Status: Needs review » Needs work
samuel.mortenson’s picture

Assigned: rjacobsen0 » aprice42
aprice42’s picture

Rerolled patch with the latest.

aprice42’s picture

This patch adds a fix to ensure the default value for a radio button is shown on the field config for a Mailchimp Subscription field.

aprice42’s picture

Assigned: aprice42 » samuel.mortenson
Status: Needs work » Needs review
Bagz’s picture

Observation: there seems to be some crossover with https://www.drupal.org/project/mailchimp/issues/2981876.

Additional comment:
This patch appears to be dealing with two issues:
- form default values missing for radio buttons
- Invalid argument supplied for foreach() in MailchimpListsSubscription->preSave() (line 285 of of MailchimpListsSubscription.php)

Since I came across the same issue I created a patch for just the form default issue. I have a feeling the other issue may already have been dealt with in the latest dev version.

I am also not sure if the default value should be a string for "select" field types as well as as radio buttons, unless the select field is a multi-value select field, i haven't had time to check or test.

I have attached my patch fwiw which deals with the form default for radio buttons (and selects) slightly differently.

gcb’s picture

Assigned: samuel.mortenson » aprice42
gcb’s picture

Assigned: aprice42 » spncr
dtrdewaele’s picture

Version: 8.x-1.x-dev » 2.2.2

xenophyle made their first commit to this issue’s fork.

Anonymous’s picture

Hi @xenophyle
There seems to be a merge conflict in MR!98 that needs to be resolved

xenophyle’s picture

Version: 2.2.2 » 2.x-dev
Assigned: spncr » xenophyle
Status: Needs review » Needs work

@akulsaxena I am working on this but need to stop for a couple hours, so it won't be ready until then.

Anonymous’s picture

Okay, Will follow the issue to see the updates,
Thanks

  • xenophyle committed 71dcac8f on 2.x
    Issue #2981031 by peacog, xenophyle, aprice42, dtrdewaele, rjacobsen0,...
xenophyle’s picture

Next step: port to 3.x.

  • xenophyle committed 25b68de5 on 3.x
    Issue #2981031 by xenophyle, peacog, aprice42, dtrdewaele, rjacobsen0,...
xenophyle’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.