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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | after-applying-patch-2.png | 9.75 KB | vinai_katiyar |
| #4 | after-applying-patch.png | 76.11 KB | vinai_katiyar |
| #4 | after-applying-patch1.png | 103.85 KB | vinai_katiyar |
| #4 | before-apply-patch-2.png | 54.37 KB | vinai_katiyar |
| #4 | before-apply-patch-1.png | 71.07 KB | vinai_katiyar |
Issue fork address-3454812
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jumoke commentedComment #3
jumoke commentedSmall patch to take out required check while hiding the dropdown when there is only one possible value.
Comment #4
vinai_katiyar commentedHi @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.
Comment #7
stomusichttps://git.drupalcode.org/project/address/-/merge_requests/72/diffs
Comment #8
anybodyLogically I disagree, but I agree that the behaviour of the field should be as close to core select fields functionality as possible!
#2995992: Country field should display the "- Select -" option to match core behavior seems very much related. Does it maybe even solve your issue here?
Still I wouldn't see this as bug?
Comment #9
anybody