When updating from 7.x-3.1 to 3.11, the subscription form I have visible in a block on the front page now adds a checkbox item with the mailing list name (defaults to unchecked). There is only one list for the form, and only one form on the entire site (a newsletter opt-in). This is confusing for users, so I reverted the update.

While I agree any single form should be able to specify the lists they are associated with in the case of multiple lists, but if it is only one item, then it should suppress display of that control, because it is meaningless. It's not the (naive) user's responsibility to specify which list, that's the point of specifying it in the signup form (admin/config/services/mailchimp/signup).

I'm marking this major, since the control defaults to unchecked, and I am assuming will not properly associate the user input (email) to the list subscription service if it remains that way.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

francismacomber’s picture

Here's a quick fix I'm using to make the single checkbox selected by default and hidden via css class "element-hidden" when there's only one list for the form.

dantodd’s picture

Unfortunately, this patch doesn't work for me.

I get this error:

patching file mailchimp_signup.module
Hunk #1 FAILED at 256.
1 out of 1 hunk FAILED -- saving rejects to file mailchimp_signup.module.rej

And this rejection report:

--- mailchimp_signup.module
+++ mailchimp_signup.module
@@ -256,18 +256,25 @@

   $list = array();
   if ($lists_count > 0) {
+    $mailchimp_list_checkbox_default = 0;
+    $mailchimp_list_checkbox_wrapper_class = "";
+    if ($lists_count === 1) {
+      // only one list hide checkbox and make it checked by default
+      $mailchimp_list_checkbox_default = 1;
+      $mailchimp_list_checkbox_wrapper_class = " element-hidden";
+    }
     foreach ($lists as $list) {
       // Wrap in a div:
       $wrapper_key = 'mailchimp_' . $list['web_id'];
       $form['mailchimp_lists'][$wrapper_key] = array(
-        '#prefix' => '<div id="mailchimp-newsletter-' . $list['web_id'] . '" class="mailchimp-newsletter-wrapper">',
+        '#prefix' => '<div id="mailchimp-newsletter-' . $list['web_id'] . '" class="mailchimp-newsletter-wrapper'.$mailchimp_list_checkbox_wrapper_class.'">',
         '#suffix' => '</div>',
       );
       $form['mailchimp_lists'][$wrapper_key]['subscribe'] = array(
         '#type' => 'checkbox',
         '#title' => $list['name'],
         '#return_value' => $list['id'],
-        '#default_value' => 0,
+        '#default_value' => $mailchimp_list_checkbox_default ? $list['id'] : 0,
       );
       if ($signup->settings['include_interest_groups'] && isset($list['intgroups'])) {
         $form['mailchimp_lists'][$wrapper_key]['interest_groups'] = array(

Any support or feedback would be most appreciated.

Dan

inky@inky3d.com’s picture

I have also reverted back to the previous version of the module, as the single check box is not useful for our purposes either.

We have one list, with multiple options under the interests. By default one should be able to force someone to signup to the mailling list if the there is only the one option on that form.

dbaasi’s picture

Version: 7.x-3.11 » 7.x-3.2

Can confirm quick fix patch works when manually applied to 7.x-3.2, thanks

wickwood’s picture

This patch worked for me as well, but I also had to manually apply it to 7.x-3.2.

Thanks for the patch

AlfTheCat’s picture

FileSize
14.47 KB

Confirming the solution in #1 works when applying the patch manually.
I've included my modifed mailchimp_signup.module file, renamed with a .txt extension to allow it to be uploaded here.

Thanks!

inky@inky3d.com’s picture

If you have interest groups within the mailing list, this patch doesn't work 100%, as the hidden element includes the checkbox and the entire interest list fieldset below it.

I've had to change line 264: $mailchimp_list_checkbox_wrapper_class = " element-hidden";

Changed "element-hidden" to the class "hide-single", and in my css I've included this:

.mailchimp-newsletter-wrapper.hide-single > .form-type-checkbox { display: none; }

In case anyone else comes across this problem.

jacktonkin’s picture

This was introduced in #2347397: Notice : Undefined index: web_id dans mailchimp_signup_subscribe_form() (ligne 290 dans [drupal_home]/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.module) when MC service is unreachable and looks like a simple counting error: checkboxes should only be displayed if there is more than one list, not one or more.

The submit handler has a special case for exactly one list so there's no need to submit hidden fields.

Attached is a one-line patch.

jacktonkin’s picture

Status: Active » Needs review
joostvdl’s picture

Patch from #8 is working for me.

Pendrokar’s picture

I am confirming this as an issue and agree with issue creator that checkboxes should show up only when there is more than one list.

gcb’s picture

That regression is no fun! I'll be rolling this patch into Dev shortly and it'll be in the next release.

  • gcb committed 154c199 on 7.x-3.x authored by jacktonkin
    Issue #2368307 by jacktonkin, francismacomber, AlfTheCat: list selection...
gcb’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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