© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
eazy

Dynamic text input value

I have the following form:
        return [
            TextInput::make('year')
                ->label(__('Year'))
                ->numeric()
                ->reactive()
                ->required(),
            TextInput::make('name')
                ->label(__('Name'))
                ->numeric()
                ->reactive()
                ->required(),
            TextInput::make('code')
                ->reactive()
                ->afterStateHydrated(function (TextInput $component, Closure $get) {
                    $year = $get('year');
                    $name = $get('name');
                    if ($year !== null && $name !== null) {
                        $component->state('xxx');
                    }
                    $component->state('123');
                })
                ->disabled()
        ];
        return [
            TextInput::make('year')
                ->label(__('Year'))
                ->numeric()
                ->reactive()
                ->required(),
            TextInput::make('name')
                ->label(__('Name'))
                ->numeric()
                ->reactive()
                ->required(),
            TextInput::make('code')
                ->reactive()
                ->afterStateHydrated(function (TextInput $component, Closure $get) {
                    $year = $get('year');
                    $name = $get('name');
                    if ($year !== null && $name !== null) {
                        $component->state('xxx');
                    }
                    $component->state('123');
                })
                ->disabled()
        ];


I want my code field's value change when the
year
year
and
name
name
input gets a value. If the
year
year
and
name
name
input is empty I want to show nothing. How can I achieve this?
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

toggle value for hide form text input
FilamentFFilament / ❓┊help
2y ago
text input
FilamentFFilament / ❓┊help
2y ago
text input
FilamentFFilament / ❓┊help
3y ago