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 Holmesβ€’3w ago
Bump
Matthew
Matthewβ€’3w ago
Have you set your togglebutton to ->live()
Adam Holmes
Adam Holmesβ€’3w ago
It sure is
Solution
LeandroFerreira
LeandroFerreiraβ€’3w ago
use in the view
{{ $evaluate(fn ($get) => $get('your_toggle')) }}
{{ $evaluate(fn ($get) => $get('your_toggle')) }}
Adam Holmes
Adam Holmesβ€’3w ago
Amazing, works a treat πŸ™‚
Want results from more Discord servers?
Add your server