The Phone Number (field) Drupal module has been incredibly useful in our projects, and we believe that the introduction of a new configuration setting would enhance its functionality and user experience.
Feature Request:
The requested feature involves the addition of a configuration setting that allows users to choose whether to display the flag alongside the country code in [specific context or page]. This option would provide greater flexibility for users who have varying preferences for the presentation of the flags within the module.
Details:
Name: Display Or Hide Flag with Country Code
Description: Introduce a configuration setting that allows administrators to choose whether to display the flag along with the country code in phone_number field in the webform.
Default Setting: Display both flag and country code.
Possible Values:
Display both flag and country code.
Display only the flag.
Display only the country code.
Benefits:
Customization: Users can tailor the display to meet their specific design and usability requirements.
User Experience: Provides a cleaner interface for users who may find the display of country codes unnecessary in certain contexts.
Internationalization: Supports users in diverse regions by allowing them to choose the level of detail in flag representation.
Implementation Suggestions:
Integrate the new configuration setting into the module's administrative interface.
Ensure backward compatibility with existing configurations.
Document the new setting in the module's documentation to guide administrators.
Please let us know if you require any further information or clarification on this request. We look forward to the possibility of seeing this feature in future releases.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | Country selection - webform element configuration.png | 15.07 KB | vaish |
| #16 | Country selection - field widget settings.png | 18.07 KB | vaish |
| #16 | Country selection - form display.png | 8.34 KB | vaish |
Issue fork phone_number-3403595
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
nikhil_dawar commentedComment #3
shubham_kumar commentedI've developed a patch to hide the flag linked to the phone number field. With this patch, no additional configurations are required.
Comment #4
shubham_kumar commentedI've noticed an additional requirement. According to your specifications, a configuration field is needed to control the visibility of the flag icon. Accordingly, I've created a patch that allows for the convenient hiding or displaying of the flag icon. To hide the flag icon, you can enable the "Disable Flag field" option in the phone element. From Your form build Settings
Comment #5
shubham_kumar commentedScreenshot For Your back-end configuration
Comment #6
shubham_kumar commentedComment #7
shubham_kumar commentedScreenshot For your Back-end form configuration
Comment #8
shubham_kumar commentedComment #9
shubham_kumar commentedScreenshot For Your backed web-form Configuration
Comment #10
nikhil_dawar commentedComment #11
nikhil_dawar commentedComment #14
mahtab_alam commentedComment #16
vaish commentedCommit in #15 improves upon the previous version in several ways.
1. Just hiding flag creates ambiguous situation for calling code +1 which is used by multiple countries. It's not possible to know which country is actually selected by looking at the country calling code alone. To solve this issue, the new commit displays two-letter country code when the flag is hidden.
2. Previous version was incomplete, it was covering only webform element but not regular Drupal core field. New commit adds the following missing features:
3. This MR also includes fix for the failed phpunit test
FunctionalJavascript\SelectCountryTest::testCountrySelect(). Failure was caused by a change introduced in Drupal 10.2. For details see comment #121 in Drupal core issue #3316274: Stabilize FunctionalJavascript testing AJAX: add ::assertExpectedAjaxRequest(). In this particular case usage ofassertWaitOnAjaxRequest()was not needed.4. Since I was already working in this area, I also did some clean up of inefficient JavaScript code in
setCountry()function.Form display

Field widget settings

Webform element configuration

Comment #17
vaish commentedComment #18
chrisolofExcellent improvements here. The current state of the MR seems to work well and does not appear to be disruptive to existing installations.
Thanks everyone!
Comment #20
vaish commented