Pick a country, searched in many ways
CountrySelect shows each country with its flag and its name in the screen’s language. It finds a country by its English name, its own name, its code or a romanized name. The panel’s preferredCountries() come first (US, CA, GB, DE and JP in this demo). It saves the two-letter code.
Note: Try it
Type Japan, 日本, JP or Nihon: each one finds 🇯🇵 Japan. Pick it and click “Show what would be saved”: JP.
Countries at the top of the list
->preferredCountries(['CN', 'VN', 'MX']) puts those countries first, in place of the panel’s.
Note: Try it
Open the list: China, Vietnam and Mexico come first under “Suggested”, then all countries.
Only some countries
->onlyCountries(['US', 'CA', 'MX']) limits the list to those countries.
Note: Try it
Open the list: only the United States, Canada and Mexico are there. Type France: nothing is found.
Several countries
It is a Filament Select, so ->multiple() works as usual and saves a list of codes.
Note: Try it
Pick Canada, then Mexico, then click “Show what would be saved”: ["CA", "MX"].
States that follow the country field
RegionSelect::make('state')->countryField('country') lists the states of the country picked in the other field (add ->live() to that field). Names are shown in the screen’s language.
Note: Try it
Pick Canada in Country: State lists Alberta, British Columbia and the other provinces. Then pick Japan: it lists Hokkaido, Aomori… instead (北海道, 青森県… on the Japanese screen).
States of one country
RegionSelect::make('prefecture')->country('JP') uses a fixed country instead of a field. It finds a state by its code, its local name, its Latin name or its ISO code.
Note: Try it
Type osaka, 大阪 or JP-27: each one finds Osaka. Pick it and click “Show what would be saved”: 大阪府, the prefecture’s own name.
How the state is saved
->storeAs() decides how the state is saved: RegionFormat::Code (the default: MA), RegionFormat::Name (Massachusetts) or RegionFormat::Iso (US-MA). A state saved earlier in another form is read and saved again in the chosen form. This field uses Name.
Note: Try it
The value saved earlier was US-MA, and the field shows Massachusetts. Click “Show what would be saved”: it is now saved as Massachusetts.
Pick a time zone
TimezoneSelect shows each time zone with its offset from UTC, its name and the time there now, grouped by continent. It finds a zone by its ID (Asia/Tokyo), its city, its country or its abbreviation (JST, EST). The zones of the panel’s country come first (the United States here). It saves the ID.
Note: Try it
Type New York, then EST, then Japan or Asia/Tokyo: each one shows the matching zones with the time there now. Pick (UTC+09:00) Japan Time and click “Show what would be saved”: Asia/Tokyo.
Time zones at the top of the list
->preferredTimezones(['America/New_York', 'Europe/London', 'Asia/Tokyo']) puts those zones first, in place of the panel country’s zones.
Note: Try it
Open the list: New York, United Kingdom and Japan come first under “Suggested”, each with the time there now.
Pick a currency
CurrencySelect shows the currencies in use today, each with a flag, its code, its name and its symbol. It finds a currency by its code, its English name or its symbol. The panel’s currency and those of its preferred countries come first. It saves the three-letter code.
Note: Try it
Type euro, then GBP, then ¥: each one finds the matching currency (¥ finds the Japanese yen and the Chinese yuan). Pick the euro and click “Show what would be saved”: EUR.
Only some currencies
->onlyCurrencies(['USD', 'EUR', 'JPY']) limits the list to those currencies.
Note: Try it
Open the list: only US Dollar, Euro and Japanese Yen are there.
Currencies at the top of the list
->preferredCurrencies(['CHF', 'SEK', 'NOK']) puts those currencies first, in place of the panel’s.
Note: Try it
Open the list: Swiss Franc, Swedish Krona and Norwegian Krone come first under “Suggested”.
Pick a language
LanguageSelect shows each language by its name in the screen’s language and its own name. It finds a language by its code or its English name. The app’s language and English come first. It saves the code.
Note: Try it
Type Deutsch or German: German — Deutsch is found. Type ja: Japanese — 日本語 is among the results. Pick it and click “Show what would be saved”: ja.
Only the languages of your app
->locales(['en', 'ja', 'pt_BR']) lists only those languages, including regional ones such as Brazilian Portuguese. Without it, the list has the two-letter ISO 639-1 languages.
Note: Try it
Open the list: only English, Japanese and Portuguese (Brazil). Pick Portuguese (Brazil) and click “Show what would be saved”: pt_BR.
Languages at the top of the list
->preferredLanguages(['fr', 'de', 'es']) puts those languages first, in place of the app’s language and English.
Note: Try it
Open the list: French, German and Spanish come first under “Suggested”.
A saved country in tables and detail pages
CountryColumn and CountryEntry show a saved code such as JP with its flag and its name in the screen’s language. ->flagOnly() shows only the flag, for narrow tables.
Note: Try it
The left one shows 🇯🇵 Japan (日本 on the Japanese screen). The right one shows only the flag 🇯🇵. The Customers list uses CountryColumn.