PHP code example of ysfkaya / filament-phone-input

1. Go to this page and download the library: Download ysfkaya/filament-phone-input library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ysfkaya / filament-phone-input example snippets


PhoneInput::make(string $name)
    ->countryStatePath(string | Closure $statePath, bool $isStatePathAbsolute)
    ->validateFor(string | array $country = 'AUTO', int | array | null $type = null, bool $lenient = false)
    ->defaultCountry(string $value)
    ->ipLookup(Closure $callback)
    ->disableIpLookup()
    ->enableIpLookup(bool | Closure $value = true)
    ->inputNumberFormat(PhoneInputNumberType | Closure $format)
    ->displayNumberFormat(PhoneInputNumberType | Closure $format)
    ->focusNumberFormat(PhoneInputNumberType | Closure $format)
    ->placeholderNumberType(PhoneInputNumberType | Closure $format)
    ->disallowDropdown()
    ->allowDropdown(bool | Closure $value = true)
    ->autoPlaceholder(string $value = 'polite')
    ->containerClass(string | Closure $value)
    ->countryOrder(array | Closure | null $value)
    ->countrySearch(bool | Closure $value = true)
    ->customPlaceholder(string | RawJs | Closure | null $value)
    ->dropdownContainer(string | null | Closure $value)
    ->excludeCountries(array | Closure $value)
    ->fixDropdownWidth(bool | Closure $value = true)
    ->formatAsYouType(bool | Closure $value = true)
    ->formatOnDisplay(bool | Closure $value = true)
    ->i18n(array | Closure $value)
    ->initialCountry(string | Closure $value)
    ->nationalMode(bool | Closure $value = true)
    ->onlyCountries(array | Closure $value)
    ->showFlags(bool | Closure $value = true)
    ->separateDialCode(bool | Closure $value = true)
    ->useFullscreenPopup(bool | Closure $value = true)
    ->strictMode(bool | Closure $value = true)
    ->cookieName(string | Closure $value)
    ->locale(string | Closure $value)
    ->customOptions(array | Closure $value)

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Infolists;
use Filament\Infolists\Infolist;
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;
use Ysfkaya\FilamentPhoneInput\Tables\PhoneColumn;
use Ysfkaya\FilamentPhoneInput\Infolists\PhoneEntry;
use Ysfkaya\FilamentPhoneInput\PhoneInputNumberType;

  
    public static function infolists(Infolist $infolist): Infolist
    {
        return $infolist
            ->columns([
                Infolists\Components\TextEntry::make('name'),
                Tables\Columns\TextColumn::make('email'),
                PhoneEntry::make('phone')->displayFormat(PhoneInputNumberType::NATIONAL),
            ]);
    }

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('name')
                    ->

PhoneInput::make('phone')
    ->countryStatePath('phone_country')

PhoneColumn::make('phone')
    ->countryColumn('phone_country')

PhoneEntry::make('phone')
    ->countryColumn('phone_country')

PhoneInput::make('phone')
    ->defaultCountry('US'),

PhoneInput::make('phone')
    ->validateFor(
        country: 'TR' | ['US', 'GB'], // default: 'AUTO'
        type: libPhoneNumberType::MOBILE | libPhoneNumberType::FIXED_LINE, // default: null
        lenient: true, // default: false
    ),

PhoneInput::make('phone')
    ->displayNumberFormat(PhoneInputNumberType::E164),

PhoneInput::make('phone')
    ->inputNumberFormat(PhoneInputNumberType::NATIONAL),

PhoneInput::make('phone')
    ->focusNumberFormat(PhoneInputNumberType::E164),

PhoneInput::make('phone')
    ->disallowDropdown(),

PhoneInput::make('phone')
    ->showFlags(false),

PhoneInput::make('phone')
    ->useFullscreenPopup(),

PhoneInput::make('phone')
    ->autoPlaceholder('aggressive'), // default is 'polite'

PhoneInput::make('phone')
    ->customContainer('w-full'),

PhoneInput::make('phone')
    ->excludeCountries(['us', 'gb']),

PhoneInput::make('phone')
    ->initialCountry('us'),

PhoneInput::make('phone')
    ->onlyCountries(['tr','us', 'gb']),

PhoneInput::make('phone')
    ->formatOnDisplay(false),

PhoneInput::make('phone')
    ->disableIpLookUp(),

PhoneInput::make('phone')
    ->ipLookup(function () {
        return rescue(fn () => Http::get('https://ipinfo.io/json')->json('country'), app()->getLocale(), report: false);
    })

PhoneInput::make('phone')
    ->placeholderNumberType('FIXED_LINE'),

PhoneInput::make('phone')
    ->countryOrder(['us', 'gb', 'tr']),

PhoneInput::make('phone')
    ->countrySearch(false),

PhoneInput::make('phone')
    ->strictMode(),

PhoneInput::make('phone')
    ->cookieName('myCookieName'),

PhoneInput::make('phone')
    ->locale('en'),

PhoneInput::make('phone')
    ->i18n([
        // Country names
        'fr' => "Frankreich",
        'de' => "Deutschland",
        'es' => "Spanien",
        'it' => "Italien",
        'ch' => "Schweiz",
        'nl' => "Niederlande",
        'at' => "Österreich",
        'dk' => "Dänemark",
        // Other plugin text
        "selectedCountryAriaLabel" =>'Ausgewähltes Land',
        "countryListAriaLabel" =>'Liste der Länder',
        "searchPlaceholder" =>'Suchen',
    ]),

PhoneInput::make('phone')
    ->formatAsYouType(false),



use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Illuminate\Support\Facades\View;
use Livewire\Component as Livewire;
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;

class Component extends Livewire implements HasForms
{
    use InteractsWithForms;

    public array $data = [];

    public function mount()
    {
        // Do not forget to fill the form
        $this->form->fill();
    }

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                PhoneInput::make('phone'),
            ])->statePath('data');
    }

    public function render()
    {
        return view('livewire.component');
    }
}
bash
php artisan filament:assets
php artisan filament-phone-input:install
blade
{{-- views/livewire/component.blade.php --}}
<div>
    {{ $this->form }}
</div>
bash
php artisan filament:assets
php artisan filament-phone-input:install