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:
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:Jump to solution
I finally did what I wanted by calling my "calculateTotalCost" in the heading() closure π
9 Replies
I wish the 'Default Section heading' was
$get('total_cost')
, even at the creation. By default, the total_cost is calculated by doing some additions of other fields or settingsI mean you probably just need to add
live
on the section π€
Should do it?I tested but unfortunately it doesn't work
Mhh i suppose you need to share more code then, because I just tested it, and it does work:
π€
Yes, I will share more code, I'm simplifiying it right now
My message is tool long so I joined my code in the message.txt file
If I intervert the group and the section, it works as I want... I do not really understand
Solution
I finally did what I wanted by calling my "calculateTotalCost" in the heading() closure π