Closed (duplicate)
Project:
Address Field
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Jun 2011 at 06:15 UTC
Updated:
3 May 2012 at 21:28 UTC
I am using Drupal 7.2 and Drupal Commerce which requires Addressfield installed.
On the customer profile form, the address form loads properly but once I choose another "Country" (any country in fact) the error message "An illegal choice has been detected. Please contact your site administrator." comes up.
I deleted the cache several times to no avail..
Comments
Comment #1
dave the brave commentedI am seeing the same issue, in my case we have 2 address fields on a single form, when one country is changed both update the state/province list BUT it seems like one or the other does not save within $form_state in the ajax call, so validation-time, its comparing an option to the incorrect list of options (in our case, US states because we default to that).
This is fairly easy to reproduce, just create 2 user address fields, and have them appear on the same form.
PS This is a fairly common scenario, e.g. a mailing and a physical/delivery address. We're also trying to copy over or hide the second address given a checkbox indicating both are the same.
Comment #2
damien tournoud commentedI cannot reproduce with the latest iteration of the code, so I guess this is fixed.
Comment #3
jyee commentedI'm seeing this error using beta1 with Drupal 7.4. Exactly the same as Damien's initial post.
Comment #4
dboulet commentedStill seeing this problem with the latest 1.x-dev version. I also have 2 address fields on the same form.
Comment #5
dboulet commentedUnearthed a few clues.
Started off by modifying lines 1284 and 1285 of form.inc:
Now, changing the Country drop down output this:
"Student" and "Pro" and options for radio buttons from another field which is required yet does not have a default value. If I choose an option for this field before changing the Country name in the address field, the error is gone. I suppose one workaround to this problem in my case would be to assign a default value for the radios.
Hope this helps.
Comment #6
jyee commented@dboulet, thanks for the workaround tip. When I set a default on an unrelated field of radios in the same form as the addressfield, the error went away.
Comment #7
docwilmot commentedsame error, and same solution works here. but not as easy for me: the other field on my form is a gender choice radios field. i cant exactly set a default gender! and it is required because, well, we all have a gender.
Comment #8
jyee commentedWhy not set a default gender as long as users can change it? The other option (and the one that I used) is to have a third option of "decline to answer"... because, while we all have a gender, it may not always be as simple as male or female (e.g. drupal.org provides a "transgender" and "other" option), nor may users always want to provide that information.
Comment #9
docwilmot commentedgood point jyee,
but i was mostly raising support for the issue at hand, which is that the module needs some work because of this. there might be some point where a form default cannot be set for someone's site.
thanks
Comment #10
davidwhthomas commentedYes, this issue only appears to occur when there's a radio button element without a default value, on the same form.
Comment #11
pcambraI can reproduce it as david says in #10. If you have a radio without default value in the same form, this error is displayed
Comment #12
robert.laszlo commentedHaving the same issue.
Comment #13
13rac1 commentedI've been dealing with this issue a lot recently. It is bug in core: #811542: Regression: Required radios throw illegal choice error when none selected
Comment #14
mobonobomo commentedSorry to post in a closed issue, but changing the widget type for your required list field to 'select list' from checkboxes/radio buttons will remove the error, and you don't have to select a default value.