Inject other field state into viewData on ViewField

Hi, I have a field that is ToggleButtons. I then have another field which is a ViewField which I would like to regenerate depending on the option that is selected in the ToggleButtons field. At the moment, the way that I do this is to use $getRecord() in the view and then look at the value in the toggle field. The problem is that it only updates when the record is saved (as you would expect). I'd like to look at the state as is in the form before saving but I can't find a way to do this because view and viewData do not accept a closure for me to pass Get $get into it. I did attempt to find the field based on the $form using getComponent but with no luck Any ideas on a simple solution for this? Thanks
Solution:
use in the view
{{ $evaluate(fn ($get) => $get('your_toggle')) }}
{{ $evaluate(fn ($get) => $get('your_toggle')) }}
...
Jump to solution
5 Replies
Adam Holmes
Adam HolmesOP4mo ago
Bump
Matthew
Matthew4mo ago
Have you set your togglebutton to ->live()
Adam Holmes
Adam HolmesOP4mo ago
It sure is
Solution
LeandroFerreira
LeandroFerreira4mo ago
use in the view
{{ $evaluate(fn ($get) => $get('your_toggle')) }}
{{ $evaluate(fn ($get) => $get('your_toggle')) }}
Adam Holmes
Adam HolmesOP4mo ago
Amazing, works a treat 🙂

Did you find this page helpful?