© 2026 Hedgehog Software, LLC

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

Save prefix values

How can I save the TextInput including the prefix? I know that I can extend the
handleRecordCreation
handleRecordCreation
method but then I would have the string prefix saved to DB (this is actually wanted and needed) but showing or editing the record would have the prefix and the prefixed string - basically double prefixed.

                Select::make('group_id')
                    ->label('Group')
                    ->relationship('group', 'code')
                    ->reactive()
                    ->required(),

                TextInput::make('code')
                    ->label('Party code')
                    ->prefix(fn (Closure $get) => $get('group_id') ? Party::find($get('group_id'))->code.'-' : '')
                    ->required(),
                Select::make('group_id')
                    ->label('Group')
                    ->relationship('group', 'code')
                    ->reactive()
                    ->required(),

                TextInput::make('code')
                    ->label('Party code')
                    ->prefix(fn (Closure $get) => $get('group_id') ? Party::find($get('group_id'))->code.'-' : '')
                    ->required(),
Solution
Some magic is happening behind the scenes I did not understood, so my workaround is:

remove
->reactive()
->reactive()
and set the value directly after update using
->afterStateUpdated(fn ($state, callable $set) => $set('code', Party::find($state)->code.'-'))
->afterStateUpdated(fn ($state, callable $set) => $set('code', Party::find($state)->code.'-'))
Jump to solution
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

Save values of Select in variable
FilamentFFilament / ❓┊help
3y ago
save repeater values as json to DB
FilamentFFilament / ❓┊help
2y ago
Locale Prefix
FilamentFFilament / ❓┊help
2y ago
Multitenant route prefix
FilamentFFilament / ❓┊help
3y ago