Skip to content

Locations 0.7.0: Country, state and city pickers on the address form

Locations 0.7.0 replaces typed country, state and city fields with pickers on the location form of the PhoenixKit locations module, stores countries as ISO codes, and shows each location’s country on the list.

Country, state and city from lists

The address block on the location form now starts with a Country dropdown (Select a country). Country names come first, not flags, so typing in the dropdown finds the country. Once a country is picked, the state and city become dropdowns where the country data has them. In the US and Canada the city list depends on the state; elsewhere it covers the whole country. Where there is no data, state and city stay plain text fields.

The labels follow the country: the state field can read State, County, Province or another local name, and the postal code field is ZIP Code for the US and Postal Code elsewhere. Under a city dropdown a hint reads Don’t see your city? Please contact the support team and we will add it. Changing the country clears the state and city; in the US and Canada, changing the state clears the city.

The warning about a similar existing address now takes the country into account. A stored location with no country still counts as a match.

Countries stored as codes

A location’s country is now stored as a two-letter ISO code such as EE, and its state as a subdivision id where the country has subdivision data. Existing rows are not migrated. Each save converts a typed name such as “Estonia” to its code, and the edit form opens an old row with the converted values already filled in. A value that matches nothing is kept as written.

The locations list gets a Country column with the country’s name, in both the table and the card view. The Sites tab on a project shows the country name instead of the stored code.

Fixes

  • The place picker checks the chosen location and space again at the final confirmation, so a place that was moved, deactivated or deleted while the picker was open can no longer be picked.
  • Saving a location type that another session deleted now goes back to Types with a not-found message instead of crashing the form.
  • A type edit address with a malformed id now redirects instead of raising an error.

Upgrading

Locations 0.7 needs PhoenixKit 2.63.0 or later (and below 3.0), the first core that brings the country library version the form reads. No migration. If your own code shows a location’s country field directly, it will now print the code; use PhoenixKitLocations.Geo.country_name/1 to show the name.

Full release notes: Locations 0.7.0

0.7.0 · 24 October 2026

Upgrade notes

  • Requires phoenix_kit >= 2.63.0 and < 3.0.0 (was >= 2.41.1). Core 2.63.0 is the first to bring beamlab_countries 2.x, whose city data the address form reads.
  • location.country is now stored as an ISO 3166-1 alpha-2 code ("EE") and location.state as a beamlab_countries subdivision id ("37", "NY") where the country has subdivision data. No migration: every write through Location.changeset/2 converts a typed or legacy name ("Estonia", "Harju") to its code, and the edit form opens an old row on the converted values. A value that matches nothing is kept as written. Host code that displays country directly should use PhoenixKitLocations.Geo.country_name/1.

Added

  • Country, state and city selectors on the location form. The address block leads with a country dropdown; state and city follow it as dropdowns where beamlab_countries has data (US and Canada list cities per state) and as text fields elsewhere, with a “contact the support team” hint for a missing city. Labels follow the country (State, County, Province / Territory; ZIP Code for the US). Country labels start with the name rather than a flag, so typing in the select finds the country.
  • The city dropdown lists every city the library has for a country, not only the ten largest.
  • A Country column on the locations list (and in its card view); the project hub’s Sites tab shows the country name instead of the stored code.
  • PhoenixKitLocations.Geo: the country, subdivision and city lookups and normalizers behind the form.
  • find_similar_addresses/5 takes a :country option; the duplicate-address warning on the form now takes the country into account (a stored location with no country still counts as a match).

Changed

  • update_location_type/3 returns {:error, :location_type_not_found} for a type deleted since the caller loaded it, including an unchanged save that used to report success.
  • Dependencies refreshed to phoenix_kit 2.64.1.

Fixed

  • PlacePicker re-checks a location (owner, type and status filters) and a space (still active, still in that location) at the final confirmation, not only when opening the tree, so it can no longer emit a place reassigned, deactivated or deleted while the picker was open.
  • Saving a location type deleted in another session redirects to Types with a not-found message instead of crashing the form.
  • /admin/locations/types/<malformed-uuid>/edit redirects instead of raising Ecto.Query.CastError; get_location_type/1 returns nil for a malformed uuid.

Locations 0.7.0. Install or update: {:phoenix_kit_locations, "~> 0.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.