© 2026 Hedgehog Software, LLC

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

Access State on an in Edit Form

This
->state(function (Model $record): float {
    return OrderItem::where("product_id", $record->id)
        ->whereHas("order", function ($o) {
            $o->where("sent", true);
        })
        ->get()
        ->sum(fn($item) => $item->quantity);
})
->state(function (Model $record): float {
    return OrderItem::where("product_id", $record->id)
        ->whereHas("order", function ($o) {
            $o->where("sent", true);
        })
        ->get()
        ->sum(fn($item) => $item->quantity);
})

works in an Infolist on a TextEntry. But on an edit form when adding it to a TextInput it returns
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

Why is it not possible to access state when editing a model? Or in other words how can i access state in an Edit Form?
Solution
->formatStateUsing()
->formatStateUsing()
I think
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Access form fields state in block preview
FilamentFFilament / ❓┊help
13mo ago
How to access form state in Custom Livewire component
FilamentFFilament / ❓┊help
5mo ago
edit form
FilamentFFilament / ❓┊help
3y ago