Webform should only list approved GoC recognized countries

Created on 5 February 2020, over 4 years ago
Updated 7 November 2023, 8 months ago

I am not sure whether this is something we should support or get Webform to have logic for but will still file issue here.

Webform should only list Government of Canada approved countries and as webform is the #1 Drupal module that all departments want to use and we have heard only positive feedback from we should address. I did something similar for the Open Data site I will try to find that hook and add it here.

Feature request
Status

Fixed

Version

5.0

Component

Code

Created by

🇨🇦Canada sylus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada optasy

    I have a proof-of-concept patch for testing the hook_countries_alter() as mentioned by @Liam Morland, this patch just deletes "Taiwan" from the country list, and I can see that is already working in the webform that I have (attached screenshot), the list can be altered as needed, but I agree with the taxonomy approach as mentioned below.

    Here's a list of GoC countries/areas of interest that I found: https://www150.statcan.gc.ca/n1/en/pub/12-608-x/12-608-x2019001-eng.pdf?...

  • Status changed to Needs review 9 months ago
  • 🇨🇦Canada joseph.olstad

    The Canadian Government has an embassy/consulate in Taiwan.

    I don't think it'd be very wise to send postage to the Canadian Embassy in Taiwan care of China. It would likely never reach destination.

    https://travel.gc.ca/assistance/embassies-consulates/taiwan

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    I understand the patch in #6 to be a demonstration of how hook_countries_alter() can be used. We should align the country list with SCCAI 2019, which is linked-to in #6.

  • Status changed to Needs work 8 months ago
  • 🇨🇦Canada SKAUGHT

    @sylus:
    Webform (Webform 6.2.x, current in v5 wxt profile) does now itself have option lists for Country/code built into it's install of new project. The webform install does created this first list from the Standard PHP Country list:
    - /admin/structure/webform/options/manage/country_names/edit
    - /admin/structure/webform/options/manage/country_codes/edit

    Scope concerns:
    a. update active sites. Have just checked, existing data is safe. the Submission Value contains full string (not abbr)
    b. profile update: hook step to ensure only the 251 countries listed in https://www150.statcan.gc.ca/n1/en/pub/12-608-x/12-608-x2019001-eng.pdf at the only after install

    I've extracted the 251 items listed in https://www150.statcan.gc.ca/n1/en/pub/12-608-x/12-608-x2019001-eng.pdf to THIS ATTACHMENT as the PDF also extraneous content to the list itself. Assume this should be the list to whitelist.
    thanks.

  • 🇨🇦Canada SKAUGHT

    patch attached.

    Outline Review:

    • adds Country Manager to items sort by Code (thus, Canada first!).
    • uses /config/data/county_names.data.yml as source from ORIGNAL PDF DATA (above). this can serve are base for changes if any. full data avail should info be needed in other scopes.
    • adds webform sort option to alpha (should wider users not want to rely on this strong guideline considering in in public Distort.
    • reminder: users could simple not use the ext_ext_webform module if they do not want to specifically override webfrom.
  • Status changed to Needs review 8 months ago
  • 🇨🇦Canada joseph.olstad

    Making Canada show up first in the list of countries makes a lot of sense given the scope of this project seeing as most of the time that will be the required selection for the target audience.

    If this is configurable that would allow other countries to adopt.

  • 🇨🇦Canada SKAUGHT

    We are locking other in given these Codes are 'in-house' as such. a much wider scope could be to make it a sort table (which is similar to webform opt). The 'Code' let Us verify Our expected items are there, given the country list info is 'real' in the first place (before we filter/whitelist)

    not sure if that scope bloat is wanted now(sort table). please let me know!
    ^again users could just disable wxt_ext_webform if they don't want to have this override.

    @documtation -- is key, of course.

  • 🇨🇦Canada SKAUGHT

    @joseph.olstad @sylus
    Have realized I've only touched the mark around making it an option for our webform submodule in this way. have also reset route and perm in this full patch. and provide an clear on page 'documentation' and link to true field settings.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    Perhaps there should be a radio button to select between SCCAI and a custom list. Only show "Select Countries to show" when it is set to custom.

    I noticed that Kosovo is written "Kosovo7".

  • 🇨🇦Canada SKAUGHT

    i may have missed the '7' foot note marker from the data sheet.
    FYI: 'data sheet' is the config now in /config/data/county_names.data.yml this is the source of truth for the list and why we see it now in the title.

    IMO: The bool checkbox is in a fieldset with legend and has a strong label, and desc. Hopefully the UX is clear enough for Admin users. I'll leave as is at this time.

    #18 Liam:
    but in mind, Future Forward :
    - what if Address Module is added in next how could we expect that to as an override option. a good common pattern is good. Bool and a link to what controls the original item seems like a good pattern IMO.
    - @profile scope: 'preferred first field' option existed(: from the CountriesManger as well as alpha/code sort. as the Code list is itself 'project directive specific'. I've personal done thinks like this before in tasks...keeping in spirit of plays-well-with-others.

    ^i'll have a patch up with the title fixes shortly.

  • Status changed to Needs work 8 months ago
  • 🇨🇦Canada SKAUGHT

    needs intro info around SCCAI

  • 🇨🇦Canada SKAUGHT

    -Adds header with links to current info sources.
    - wrap checkboxes in open details. reduce some visual clutter in this respect.

  • Status changed to Needs review 8 months ago
  • 🇨🇦Canada optasy

    I tested this patch and works as expected, I was able to set the countries that are displayed in the webform address field:

  • 🇨🇦Canada SKAUGHT

    - cleanup last 'CND Code', data sheet filename harmony. typo in webform desc.

  • 🇨🇦Canada danrod

    Tested patch #25 myself, works as expected, I attached a few screens.
    I don't see SCCAI codes for a few territories (Ceuta and Melilla, Diego Garcia), but I don't think it is a big deal.

  • 🇨🇦Canada SKAUGHT

    @danrod
    this is because at the base of this request these 'end items' are the countries that are Not in the 'area of interest' to the Stats Canada. These are the countries that should remain 'off' by all official CND/Stats Can Sites.

    Whereas any other group using the Wxt Profile (a public, global distro), still have the option to list those countries (or more simply, not use the 'webform override' it they do not want to 'ensure countries are overridden'.

    Reminder for all, others: the full Country list as the list is provided by PHP itself, these are parts of Region and Time data build into PHP's general runtime of information.

    thanks!

  • Status changed to RTBC 8 months ago
  • 🇨🇦Canada sylus

    @smulvih2 can you take a look at this as well?

    I think we should also add this to our overview page linking to this issue under wxt_ext_webform so people don't miss additional features being added like this.

    https://drupalwxt.github.io/docs/general/overview/

    Anyways first impression is this is amazing work as I have in the past heard this request a fair bit.

    It also aligns with us trying to be a reference implementation to show solutions to some common patterns in the GoC and elsewhere.

  • 🇨🇦Canada smulvih2 Canada 🍁

    Will try this patch locally later today/tomorrow and report back.

  • 🇨🇦Canada smulvih2 Canada 🍁

    This is pretty cool, works well!

    I added a select list to one of the default webforms. For the element options config I selected "Country names". The options were correctly showing and I was able to toggle countries on/off as needed. Sorting works as well. I like how the webform results show the country name and not the ID.

    To update the country list, looks like we just update sccai_county_names.yml and it should work.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    The screenshots make it look like users need to manually select a list of countries. Is that right? It would be easier to use if there was a single checkbox that would cause it to use the countries in SCCAI.

  • 🇨🇦Canada SKAUGHT

    the items in the list come pre-selected/enabled. this is config based.

  • Status changed to Fixed 8 months ago
  • 🇨🇦Canada sylus

    Thank you so much @SKAUGHT and @OPTASY for all of the amazing work.

    I'm very appreciative of this you have no idea. :)

    As well thank you to everyone for all of the reviews and +1's.

    Teamwork makes the dream work.

    Committed and attributed!

  • 🇨🇦Canada SKAUGHT

    looking forward to seeing Canada first when I (as a real user) may have to fill out a GoC contact form! cheers.

  • 🇨🇦Canada joseph.olstad

    Not sure if this is working as expected

    wxt_core_countries is created when upgrading to the latest wxt, however there's no module called wxt_core_countries

    I haven't spent much time looking into this but there's possibly an issue here, or it could just be a cache rebuild required
    I basically don't have much time to look into it so for my test environment I'm just going to remove wxt_core_countries.settings.yml

  • 🇨🇦Canada smulvih2 Canada 🍁

    @joseph the wxt_core_countries.setting file is the editable config for the CountriesWhitelistForm form. Maybe this should be wxt_core.countries.settings instead?

  • 🇨🇦Canada joseph.olstad

    @smulvih2 , yes I suspect that it should be called wxt_core.countries.settings instead or whichever name that makes sense.

    I believe the first segment is the associated module machine name.

  • 🇨🇦Canada SKAUGHT

    It is true this is around namespacing. I did more simply just name the config this while building it, not to associate with a module namespace.

  • Status changed to Active 8 months ago
  • 🇨🇦Canada joseph.olstad

    Likely should be changed to:
    wxt_core.settings.countries

  • Status changed to Fixed 8 months ago
  • 🇨🇦Canada smulvih2 Canada 🍁

    @joseph let's open a new ticket for this since it has already been merged with dev branch, and make this a related ticket. Makes it easier later on to track these changes.

  • 🇨🇦Canada joseph.olstad

    @smulvih2 yes good suggestion, thanks :)

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

Production build 0.69.0 2024