Skip to main content
← Back to Table of Contents

Summary

Searchable country picker with circle flags. Stores a single ISO 3166-1 alpha-2 code. Offers the 249 officially assigned ISO 3166-1 entries by default, including dependent territories. Add non-ISO regions explicitly when your application needs them. Flags are local SVG assets shared with PhoneField.

Basic usage

Standard country picker

Whitelist and browser detection


State & validation

Stored value

State is a single uppercase two-letter country or territory code. The default catalog accepts ISO 3166-1 codes; explicitly enabled non-ISO regions are also accepted.
Country labels, dialing descriptions and flag URLs are presentation metadata. They are never included in the field’s dehydrated value. Save the form’s validated getState() result to a string column; a JSON cast is unnecessary for this field.

Validation rules

Built-in validation ensures the submitted code is in the resolved country list.
Validation runs against the submitted value before display normalization. Labels such as Poland, unknown codes, excluded markets, numeric values and arrays are rejected. required() rejects an empty value. Hydration can normalize an existing lowercase code, but the browser submits uppercase identities. These rules apply when saving through Filament’s validated form state.

Configuration API

All methods accept Closure unless noted.

countries() / exceptCountries()

Limit the list to specific markets:

showDialCode()

Useful for address forms where phone context is helpful:

Real-world examples

Shipping address form

ISO + Kosovo

XK is user-assigned, not an officially assigned ISO country code. The other available extensions (AC, DG, EA, IC, TA) are also excluded by default. Adding a region does not bypass countries() or exceptCountries(). Unknown codes remain excluded. Applications migrating from the former 255-entry list can opt into all six regions:
PhoneField uses libphonenumber’s supported telephone regions, independently of this address-country catalog. An ISO territory without a calling-code region can still be selected in CountryField; showDialCode() leaves its dialing description empty.

Multi-language support

Country names follow app()->getLocale() by default (Poland / Polska) from package translation overrides, then PHP ICU regional names. English names are a final fallback when ICU is unavailable. Both the initial render and the dropdown use the same names. Pin a language per field with locale(), independently of the panel locale:

Playground

/admin/flex-fields/country-field See Playground for setup.

Performance

Flags are installed with the package and published through the regular FLEX asset pipeline. Use the same deployment steps described in Installation:
No extra npm package or browser-side translation library is needed. Each flag uses a versioned local URL; opening the picker does not fetch the full flag collection. The circular artwork is from HatScripts/circle-flags, pinned to a recorded commit with the MIT license retained in the package. When using the JSON/schema builder, configure additional_regions with the same list, e.g. ['additional_regions' => ['XK']]. Direct CountryField instances have no selected country by default; the schema builder’s default configuration uses PL. In the dropdown, rows with only a country name use the same flag size as PhoneField. Rows with a name and a second-line code or dialing description use a slightly larger flag, scaled for the field’s sm, md or lg size. PhoneField’s compact flag sizing is unchanged.
Last modified on October 16, 2026