Skip to content

improve how we get parents for subdivision fields#15584

Merged
brandonkelly merged 4 commits into4.xfrom
bugfix/15551-address-subdivision-parents
Aug 26, 2024
Merged

improve how we get parents for subdivision fields#15584
brandonkelly merged 4 commits into4.xfrom
bugfix/15551-address-subdivision-parents

Conversation

@i-just
Copy link
Copy Markdown
Contributor

@i-just i-just commented Aug 23, 2024

Description

Background:
When getting a list of options for subdivision fields, you need to pass an array of parents to the SubdivisionRepository->getList() method. Passing null is meaningful here.

Problem:
With the current way of getting the parents array, wrong data will be returned in certain cases. For example:

  • no list will be returned for Andorra’s locality field, but there should be (v4 and v5)
  • if you haven’t opted into using counties (administrative areas) for the UK, a list of counties will still be returned and incorrectly used for the locality (city) field (in v5 only; in v4, locality will be a plain text field).

Solution:
Check both the visibility of the parent fields as well as the original list of options for the parent field when determining if the field value should be included in the parents array.

Tested against v4 and v5.

Test examples:

  • Andorra should have a dropdown list under the “City” field
  • United Kingdom without counties (default):
    • v4: “Post Town” should be a plain text field
    • v5: “City” should be a plain text field
  • United Kingdom with added counties ('administrativeArea' field added via Addresses::EVENT_DEFINE_USED_FIELDS):
    • v4: “Province” (label might be renamed, but that’s the default) should be a dropdown list of counties, “Post Town” should be a plain text field
    • v5: “Province” (label might be renamed, but that’s the default) should be a dropdown list of counties, “City” should be a plain text field
  • Chile should have a dropdown list under the “Region” and “City” fields (e.g. Region: Araucania; City: Carahue
  • China should have a dropdown list under the “Province”, “City” and “District” fields (e.g. Province: Heilongjiang Sheng, City: Hegang Shi, District: Dongshan Qu)

Related issues

#15551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants