composer require ysfkaya/filament-phone-input
php artisan filament:assets
php artisan filament-phone-input:install
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;
PhoneInput::make('phone')
use Ysfkaya\FilamentPhoneInput\Tables\PhoneColumn;
PhoneColumn::make('phone')
use Ysfkaya\FilamentPhoneInput\Infolists\PhoneEntry;
PhoneEntry::make('phone')
Replace a standard TextInput for phone numbers in a user profile form:
public static function form(Form $form): Form
{
return $form->schema([
TextInput::make('name'),
PhoneInput::make('phone') // Replaces TextInput for phone
]);
}
PhoneInput::make() directly in form schemas.validateFor() to enforce phone number rules:
PhoneInput::make('phone')
->validateFor(country: 'US', type: libPhoneNumberType::MOBILE)
PhoneInput::make('phone')
->countryStatePath('phone_country')
PhoneColumn::make('phone')
->displayFormat(PhoneInputNumberType::NATIONAL)
PhoneColumn::make('phone')
->countryColumn('phone_country')
PhoneInput::make('phone')
->onlyCountries(fn () => ['US', 'GB'])
PhoneInput::make('phone')
->ipLookup(fn () => request()->ip())
PhoneInput::make('phone')
->locale('tr')
validation.php.getFormSchema()).Laravel Phone methods for validation/storage:
$phone = Phone::make($request->phone);
$phone->formatE164(); // Use Laravel Phone's utilities
intl-tel-input. Ensure:
php artisan filament:assets
is run after installation.Number requires a country to be specified or Number does not match the provided country.defaultCountry or ensure stored numbers include area codes:
PhoneInput::make('phone')
->defaultCountry('US')
countryStatePath.$fillable.disableLookup() not working.validateFor() is chained before required() if using both.$this->form->fillableData['phone']; // Check raw value
php artisan filament:assets
/vendor/ysfkaya/filament-phone-input/....validation.php for custom messages:
'attributes' => [
'phone' => 'phone number',
],
'custom' => [
'phone' => [
'required' => 'The :attribute is required.',
],
],
intl-tel-input options:
PhoneInput::make('phone')
->customOptions(['preferredCountries' => ['tr', 'us']])
PhoneInput::make('phone')
->onlyCountries(fn () => Country::query()->pluck('code')->toArray())
// Publish views first:
php artisan vendor:publish --tag=filament-phone-input-views
Then modify resources/views/vendor/filament-phone-input/....Laravel Phone for unit tests:
$this->partialMock(Phone::class, function ($mock) {
$mock->shouldReceive('parse')->andReturn(new PhoneNumber());
});
PhoneInput::make('phone')
->disableLookup()
PhoneInput::make('phone')
->useFullscreenPopup()
PhoneInput::make('phone')
->showFlags(false)
i18n for multi-language support:
PhoneInput::make('phone')
->i18n(['tr' => 'Türkçe'])
How can I help you explore Laravel packages today?