Skip to main content
PhoneField ← Back to Table of Contents

Summary

International phone input with searchable country picker, libphonenumber validation, and structured state (country, national, e164).

Basic usage

Load from an E.164 string on edit:
Store only E.164 in the database:

State format

On hydrate and dehydrate, normalizeState() runs automatically. A plain string state (e.g. +48 512 345 678) is parsed on hydrate. Default national stays NATIONAL-formatted for BC; use digits-only or e164 when you need machine-friendly values.

Validation

Do not combine mobileOnly() and fixedLineOnly() on the same field — throws InvalidArgumentException. Prefer allowTypes() for multi-type rules.

Configuration API

variant(string|Closure $variant)

Visual style shared with FlexTextInput. Values: primary (default), secondary, flat, soft.

size(string|ControlSize|Closure $size)

Control height. See Control size. Default: md.

defaultCountry(string|Closure $countryCode)

ISO country code when no country is selected. Default: PL. Falls back to first allowed country or US.

countries(array|Closure|null $countries)

Whitelist of ISO codes. null = all countries (minus exceptCountries).

exceptCountries(array|Closure $countries)

Blacklist applied after the whitelist. Default: [].

searchable(bool|Closure $condition = true)

Show search input in the country dropdown. Default: true.

suffixIcon(string|BackedEnum|Htmlable|Closure|bool|null $icon = null)

Trailing icon. Pass false to hide. Pass an icon name to set a custom icon. Default: config filament-flex-fields.ui.phone_suffix_icon or GravityIcon::Smartphone.

internationalPrefix(bool|Closure $condition = true)

Show dial code prefix next to the national input. Default: true.

mobileOnly(bool|Closure $condition = true)

Restrict to mobile numbers.

fixedLineOnly(bool|Closure $condition = true)

Restrict to fixed-line numbers.

browserLocaleDefault(bool|Closure $condition = true)

When enabled and national number is empty, pre-select country from Accept-Language / browser locale.

browserLocaleSortFirst(bool|Closure $condition = true)

Sort country list with browser locale country first.

locale(string|Closure|null $locale)

Language for country names in the picker (en → Poland, pl → Polska). Defaults to app()->getLocale().

placeholder(string|Closure|null $placeholder)

Inherited from Filament HasPlaceholder. When omitted, the field uses a libphonenumber national example for the default country (and mobile/fixed type when constrained), otherwise the package language string.

allowTypes(array|Closure|null $types)

Restrict accepted libphonenumber number types (PhoneNumberType cases or names like MOBILE, VOIP). When set, overrides mobileOnly() / fixedLineOnly() sugar.

strictTypes(bool|Closure $condition = true)

Do not auto-accept FIXED_LINE_OR_MOBILE alongside MOBILE / FIXED_LINE.

validateForRegion(bool|Closure $condition = true)

Require isValidNumberForRegion() for the selected country (stricter than global isValidNumber).

nationalFormat(PhoneNationalFormat|string|Closure $format) / nationalDigitsOnly()

Default national (BC). Digits-only is opt-in:

includeFormats(array|Closure $formats)

Add international and/or rfc3966 keys to dehydrated state (valid numbers only).

includeMetadata(array|Closure $metadata)

Add PHP-side carrier, geo, timezones, and/or type keys (valid numbers only). No JS / phone-lib budget impact.

readOnly(bool|Closure $condition = true)

Inherited from Filament CanBeReadOnly.

focusOutline(bool|Closure $condition = true)

Inherited from HasFieldFocusOutline.

Public helper methods

FlexField schema config

CSS classes

Shares FlexTextInput shell classes (fff-flex-text-input-field, variant modifiers).

Implementation notes

  • Country dropdown uses x-teleport="body" to avoid overflow clipping.
  • Depends on giggsey/libphonenumber-for-php for parsing and validation.
  • Empty national number dehydrates to e164: '' regardless of partial dial prefix.

Playground

Slug: phone-field /admin/flex-fields-playground/phone-field — see Playground.