© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•15mo ago•
3 replies
mathieutu

Computed state in form fields.

Hi,
I'd like to have the state totally computed in some form fields.
The state would be calculated with a function, and refreshed at each render.
Like a
Placeholder
Placeholder
, but with real fields.
Basically doing the same as we can with
disabled
disabled
, or
readOnly
readOnly
but with the state.

On the table, we can use
getStateUsing
getStateUsing
:
Tables\Columns\TextColumn::make('foo')->getStateUsing(fn ($record) => Foo::compute($record))
Tables\Columns\TextColumn::make('foo')->getStateUsing(fn ($record) => Foo::compute($record))


Setting the state directly using
state(fn() => ...)
state(fn() => ...)
on a TextInput throws an error:
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
(in the
getLivewire
getLivewire
function).

Is it something easily possible?


Could we add a
getStateUsing
getStateUsing
to the input as well? (I can open a PR)

Thanks!
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

Access form fields state in block preview
FilamentFFilament / ❓┊help
13mo ago
Form state for fields with relationship
FilamentFFilament / ❓┊help
3y ago
Equivalent of novas computed fields?
FilamentFFilament / ❓┊help
2y ago
Calculated fields in form builder
FilamentFFilament / ❓┊help
3y ago