Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve how we get parents for subdivision fields #15584

Merged
merged 4 commits into from
Aug 26, 2024

Conversation

i-just
Copy link
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