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


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\Infolists\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('polite'), // default is 'aggressive'

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')
    ->preferredCountries(['tr','us', 'gb']),

PhoneInput::make('phone')
    ->showSelectedDialCode(true),

PhoneInput::make('phone')
    ->autoInsertDialCode(true),

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

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 $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');
    }
}
blade
{{-- views/livewire/component.blade.php --}}
<div>
    {{ $this->form }}
</div>
bash
php artisan filament:assets