Problem/Motivation
When submitting a signup form for a single list while multiple lists are available in the account, the form validation will consistently return the error "Please select at least one list to subscribe to.", even though list checkboxes are not shown to the user.
Proposed resolution
It is plausible the user wants to subscribe to the single configured list, hence no checkboxes being shown. There is however an error in the validation method. The size of $signup->mc_lists is checked to be bigger than 1. When multiple lists are available, the array is always bigger than one. The values in the array are either the list ID or 0, the latter being the case when the list is not configured for subscription. Thus, as also done in the submit method, the array should be passed through array_filter() before count().
Remaining tasks
-none-
User interface changes
-none-
API changes
-none-
Data model changes
-none-
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | mailchimp-signup_single_list_error-2654978-24.patch | 1.29 KB | bart vanhoutte |
| #17 | mailchimp-signup_single_list_error-2654978-17.patch | 529 bytes | henk |
| #9 | mailchimp-signup_single_list_error-2654978-9.patch | 817 bytes | dietr_ch |
| #2 | mailchimp-signup_single_list_error-2654978-2.patch | 737 bytes | dietr_ch |
Comments
Comment #2
dietr_ch commentedAttached patch with fix as described in the solution.
Comment #3
dietr_ch commentedComment #9
dietr_ch commentedI just noticed the issue does not appear anymore since commit d4a8a102e9a03779af660c1bf8365185dce91ed8. However this has disabled the list checkbox validation altogether: when the form displays checkboxes and none is checked, the form will no longer show "Please select at least one list to subscribe to".
I rerolled the patched to the latest dev version before reverting above commit, so the validation works as expected.
Comment #15
dietr_ch commentedComment #16
henk commentedI have the same problem. PHP 7 and PHP 5.5. I will review your patch now.
Comment #17
henk commentedI see that problem is not in the validation but creation of form.
Line 79
If $lists_count is array with one value will not pass the if. In my opinion should more that 0:
Line 79
Also If we have only one mailchimp list '#checkbox' can be change to '#value'.
Comment #23
ruscoe commentedI'm unable to reproduce this. Could you try with the current dev branch and update this issue if there's still a problem?
git clone --branch 8.x-1.x https://git.drupal.org/project/mailchimp.gitComment #24
bart vanhoutte commentedThe issue seems to be fixed in the latest dev branch. However, the opposite has been introduced. If there's a form that has more than one list, validation passes even though no list has been selected.
Comment #25
asrobI 've successfully applied this patch and looks good to me. That's why RTBC'ed!
Comment #27
amytswan commentedThanks everyone for your contribution to this issue! I've pushed @Bart Vanhoutte's patch to the 8.x-1.x-dev branch - it's queued to go out in our next release.