Hi folks
I am currently running drupal 6.x and Mailchimp Module but got an error
"An illegal choice has been detected. Please contact the site administrator."

This problem appears when i create new user or register a new account where "Subscribe Checkbox of Mailchimp Module" is enabled at these page

For example: http://localhost/drupal/admin/user/user/create

I disable Auto Subcribe Checkbox from Mailchimp Modules and the problem disappears

This should be fixed as soon as possible

CommentFileSizeAuthor
#7 Picture 1.png19.18 KBnetsensei
#5 mailchimp-issue.patch1.63 KBnetsensei
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Poieo’s picture

Seeing this issue as well. Except I'm seeing it when interest groups are included in the registration block. With interest groups I receive the error upon registration. Without, no error.

levelos’s picture

Status: Active » Postponed (maintainer needs more info)

I still can't recreate. Have you tested with the latest dev snapshot?

Poieo’s picture

Seems to be working with the latest dev. The issue was with RC5.

levelos’s picture

Status: Postponed (maintainer needs more info) » Fixed

Great, I'm closing then.

netsensei’s picture

Version: 6.x-2.0-rc5 » 6.x-2.x-dev
Status: Fixed » Needs review
FileSize
1.63 KB

This is not fixed.

I installed the Mailchimp module 2.0 (july 12th) but I got the same error too. The error is also not fixed in the dev version.

Upon closer review, it seems that the _mailchimp_subscribe_anon_form() function builds an erroneous $form array when it comes to the INTERESTS form element. Depending on the field type, the #type property is set to either radios, checkboxes or something else. Nonetheless, the #options property is set in all cases.

Apparently, the data from the listInterestGroups() call can also contain data with field type 'hidden'. The Form api doesn't allow an #options property for elements of type 'hidden'.

Hence the validation error.

Made an attempt to build a patch which works form me. But I'm not really acquainted with the MailChimp API to know what other field types (besides 'hidden', 'checkboxes' and 'radios') the call might trigger.

levelos’s picture

Status: Needs review » Needs work

According the API documentation, listInterestGroups() only returns field types of checkbox, radio, select. Under what circumstance are you getting a hidden type back? Not clear on why an interest group would presented by MC would ever be hidden, and if it was, we should just discard it entirely, e.g.,

if ($intgroup = $q->listInterestGroups($list->id) && $intgroup['form_field'] != 'hidden') {
 ...
}
netsensei’s picture

FileSize
19.18 KB

Yes, I've just taken a look into the interface. The group is set as "Hidden". I didn't see a setting to change it into something different.

levelos’s picture

Status: Needs work » Fixed

Took a bit of a different approach, but fixed and committed to 6.2 branch.

Status: Fixed » Closed (fixed)

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

Sinan Erdem’s picture

Version: 6.x-2.x-dev » 7.x-2.9
Component: Code » General
Status: Closed (fixed) » Active

I am experiencing the same issue on the latest 7.x version. I have set some fields as hidden and not required from Mailchimp side. There are 5 of those fields. But when a user fills out a form in Drupal, it gives me 5 of those errors:

An illegal choice has been detected. Please contact the site administrator.
An illegal choice has been detected. Please contact the site administrator.
An illegal choice has been detected. Please contact the site administrator.
An illegal choice has been detected. Please contact the site administrator.
An illegal choice has been detected. Please contact the site administrator.

gcb’s picture

Status: Active » Postponed (maintainer needs more info)

Sinan, can you clarify what sort of fields your are setting as "hidden" and how? I can only find a way to set fields as hidden when generating a Mailchimp List Form using the Mailchimp interface (/lists/designer/ on my MC account). This form has nothing to do with the Drupal Mailchimp module, though, but is instead a way to get subscribe forms embedded using nothing but basic HTML.

Also, you have tagged this under 2.9 but stated that you are on the latest version, which is 2.10. If that's true, please select the correct version in the drop-down (it's alphabetical so it shows up between 2.1 and 2.2).

Sinan Erdem’s picture

Version: 7.x-2.9 » 7.x-2.7

@gcb,

I am sorry, I now see that I am using 7.x-2.7.

Yes, I am setting the fields (dropdown or radios) as hidden on that Mailchimp List Form. When I do that, Drupal form doesnt show those hidden items. The output of a hidden field on Drupal form becomes:

achilleas01’s picture

Version: 7.x-2.7 » 7.x-2.10
Status: Postponed (maintainer needs more info) » Active

Hello,
we have added the chargebee service and the mailchimp module adds some hidden fields to the drupal form as
the following HTML code shows:

When you submit the form it produces the error

An illegal choice has been detected. Please contact the site administrator.
An illegal choice has been detected. Please contact the site administrator.
An illegal choice has been detected. Please contact the site administrator.
An illegal choice has been detected. Please contact the site administrator.

I then changed the code of mailchimp/modules/mailchimp_lists/mailchimp_lists.module
in line 532 i added this to exclude checking of these hidden fields
$tagnames = array('LNAME','SUB_HANDLE','MMERGE10','IS_TRIAL','PLAN_CODE','PLAN_NAME','SUB_SINCE','SUB_STATUS','TRIAL_END');
if(!in_array($mergevar['tag'], $tagnames)) {

and i bypass them and the error is gone.
Can you help us to find a better solution to avoid these error?
Thank you

gcb’s picture

Status: Active » Postponed (maintainer needs more info)

It looks like this issue occurs when plugins are added to your mailchimp service? Interesting. The latest Development release (which should soon become 7.x-2.11) has configuration options to change the fields made available to anonymous users completing these forms. Can you try it out and tell us if the issue persists? if you can work around it by removing those fields on the list configuration page for anonymous-allowed lists?

Lukas von Blarer’s picture

Version: 7.x-2.10 » 7.x-3.x-dev
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

I encountered this error as well. Debugging revealed, that somewhere #default_value is being set for merge fields. If this happens for radios which was my case, this throws an error when validating because is #default_value empty and therefore is not an allowed value. My merge field was called store and therefore this inside a hook_form_alter() solved the issue:

<?php
function weinberg_project_form_alter(&$form, &$form_state, $form_id) {
  unset($form['mergevars']['STORE']['#default_value']);
}
?>

How do we fix this?

ruscoe’s picture

Status: Active » Closed (won't fix)

We're going to be ending support for the 7.x-3.x branch due to the upcoming deprecation of the v2.0 MailChimp API. If you're still seeing this issue with the most recent release, please feel free to reopen.