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);
})

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

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
Was this page helpful?