© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
vahnmarty

How to reuse a Form Field?

In using a DRY principle, I want to use Phone input that can be use in all forms. Currently, I've been copy-pasting them accross pages.

TextInput::make('phone')
        ->disableLabel()
        ->label('Phone Number')
        ->placeholder('Phone Number')
        ->validationAttribute('Phone Number')
        ->minLength(10)
        ->maxLength(14)
        ->mask('(999) 999-9999')
        ->stripCharacters(['(', ')', ' ', '-'])
        ->numeric()
        ->rules([ new PhoneNumberRule, 'doesnt_start_with:1'])
        ->required()
        ->validationMessages([
            'doesnt_start_with' => 'Phone Number cannot begin with 1.',
        ]),
TextInput::make('phone')
        ->disableLabel()
        ->label('Phone Number')
        ->placeholder('Phone Number')
        ->validationAttribute('Phone Number')
        ->minLength(10)
        ->maxLength(14)
        ->mask('(999) 999-9999')
        ->stripCharacters(['(', ')', ' ', '-'])
        ->numeric()
        ->rules([ new PhoneNumberRule, 'doesnt_start_with:1'])
        ->required()
        ->validationMessages([
            'doesnt_start_with' => 'Phone Number cannot begin with 1.',
        ]),


So instead of this, is there a way I can use
PhoneInput::make('primary_phone')
PhoneInput::make('primary_phone')
?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Form schema reuse
FilamentFFilament / ❓┊help
6mo ago
Reuse form componenets
FilamentFFilament / ❓┊help
3y ago
how to hide a form field conditionally?
FilamentFFilament / ❓┊help
3y ago
Reuse a Form Resource in createOptionForm
FilamentFFilament / ❓┊help
3y ago