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() I think
Jump to solution
2 Replies
Solution
LeandroFerreira
LeandroFerreira5mo ago
->formatStateUsing() I think
JJSanders
JJSanders5mo ago
Legend. Thanks!!!!!
Want results from more Discord servers?
Add your server
More Posts