Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
- Enable either the location_node module or the location_cck module
- Set up a country field and province field in a content type
- Create a new node and select a country (e.g. UK) and a province (e.g. Cheshire) and save the node
- Edit the node, change the country (e.g. Canada), select a new province (e.g. Prince Edward Island)
- Save the node - you should get an error message: "An illegal choice has been detected. Please contact the site administrator.".
Proposed resolution
Line 283 in location.module in function _location_expand_location() checks if ['value']['country'] is set on the current element, and if not, uses the default country to determine the list of provinces. This should most probably be checking ['#value']['country'] on that element, as ['value']['country'] is not present on this element even where a country has been selected on the form. Patch attached.
I am guessing that this bug may have been introduced at some point since 6.x-3.2 as that version appears to check for ['#value']['country'].
Remaining tasks
Needs testing.
Comment | File | Size | Author |
---|---|---|---|
#9 | location-2139429-9.patch | 909 bytes | roball |
Comments
Comment #1
neilt17 CreditAttribution: neilt17 commentedComment #2
Summit CreditAttribution: Summit commentedHi,
Great catch, I had to change this also to get it to work!
Thanks!
Greetings, Martijn
Comment #4
gpvdo CreditAttribution: gpvdo commentedPlease see 'location_element' in Drupal form with Country/Province(select) AJAX update
Changing ['value']['country'] to ['#value']['country'] is needed but not sufficient else one could run into validation errors.
Comment #5
roball CreditAttribution: roball commentedGetting the same error on all D6 sites since updating Location from 6.x-3.2 to 6.x-3.3.
Comment #6
roball CreditAttribution: roball commentedTrying to make the testbot happy
Comment #9
roball CreditAttribution: roball commentedRe-rolled patch in correct Drupal format.
Comment #10
roball CreditAttribution: roball commentedThe bug has been introduced with commit 20e15f on 2013-09-10, released in version 6.x-3.3-rc1, on trying to fix #2084133: Illegal string offset 'country' in location/location.module on line 282..
podarok, could you please commit the patch from #9 above which fixes the bug? I have tested it and can confirm that it indeed fixes the issue. Thanks.
Comment #11
joelpittetRTBC++
Comment #12
podarokthanks, fixed.
Comment #14
roball CreditAttribution: roball commentedThanks podarok for committing and releasing Location 6.x-3.4!
Comment #15
podarokYou are welcome
I have no more sites with 6.x version, so it is possible to get it supported due to community activity only