Hide Country if the only option

Created on 15 June 2024, 10 months ago
Updated 29 July 2024, 8 months ago

Problem/Motivation

This module hides the country field if it's the only option AND the address field is required. However, there would be cases where the address field is not required, yet it's the only option which has also been set as default. For that case, it is still necessary to hide the Country.

Steps to reproduce

In our case, we are using the require_on_publish module to require only when the content is being published. So the extra check on 'required' does not help, as it's logical to still have the Country hidden when it's the only option.

Proposed resolution

Remove the extra required check from the logic that hides the country when it's the only option.
I will follow up with a patch for this.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇸United States jumoke

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

Comments & Activities

  • Issue created by @jumoke
  • 🇺🇸United States jumoke
  • Status changed to Needs review 10 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 10 months ago
    43 pass
  • 🇺🇸United States jumoke

    Small patch to take out required check while hiding the dropdown when there is only one possible value.

  • 🇮🇳India vinai_katiyar Delhi NCR

    Hi @jumoke,

    I have tested the patch mentioned in #3. It hides the Country field when the dropdown contains only one country, and the Address field is not required. However, I observed that if the Address field is set as non-mandatory and a default country is specified, then by default, Address module provides two options for the Country field: "None" and the default country. If "None" is selected, then the Address field will not be displayed to the web user.

    After applying patch #3, the "None" option is no longer available, preventing the Country field from being hidden from the web user.

    Kindly refer to the attached screenshots.

Production build 0.71.5 2024