Update section heading programmatically

Hello,

Is it possible to update a section heading programmatically? Or display a form field in it?

I would like to display a "total cost" calculated with other fields of the form, in the heading of a section.

The issue is that I put a value in the heading like so:

Forms\Components\Section::make()
    ->heading(fn(Get $get): string => (string) $get('total_cost'))


But my "total_cost" field is not defined on a creation form, because it's calculated after some fields are updated.

How can I force the update of the heading? IS there a "boot" method on form builder?
Solution
I finally did what I wanted by calling my "calculateTotalCost" in the heading() closure 👍
Was this page helpful?