address_country_unknown
Overview
The Address Country Unknown module is extending the functionality of the Address module. It provides custom widgets and formatters that allow users to enter, save, and display an address even when the country is (semantically) unknown = left empty (technically).
This is a(n ugly) workaround - take care!
The module implements a workaround that solves the issue of not being able to enter an address without country (because country may not be known in real-world scenarios and the address doesn't need to be complete in these cases, as it's just information text), but because the Address module does not support this (for some good reasons), the implementation is kind of ugly.
NEVER use this in combination with Drupal Commerce which heavily relies on complete addresses!
Do not use in production without reading the code and documentation carefully. (Only for developers who know what they're doing ;))
So probably this module will never have a stable release.
Why We Implemented It
By default, the Drupal Address module strictly requires a country to be selected. The chosen country dictates which address fields (like state, zip code, or province) are displayed and validated, based on that specific country's official address format.
However, there are real-world scenarios where an address needs to be recorded, but the country is either unknown, incomplete, or not applicable. In the default setup, leaving the country blank completely clears and hides the rest of the address fields. See #3522596: Allow country to be empty if unknown
We implemented this module to solve that exact problem. It overrides the default restrictive behavior by allowing to select no country for an address, still showing the address fields and providing a generic address format when no country is selected. This ensures that users can still input and display essential address information without needing to provide a country.
Furthermore, migrated data which is missing country codes but holds other address data won't get cleared automatically.
If a country is selected, the module uses the default Address implementation and logics.
Usage
To use this functionality, simply select the "Address (with empty / unknown country)" widget and formatter(s) on your address fields in your entity's form and display settings.
IMPORTANT: The formatters and widgets are required to be used together! Don't mix them with the default Address widgets / formatters, or you'll see errors or unexpected behaviour!
Also note that if this module is enabled, all address fields in the project are replaced by the custom implementation. See the module file for details.
Alternatives
- Don't use Address module for addresses with possibly empty / unknown country, but use text fields instead
- https://www.drupal.org/project/simple_address