multiple fields calculation to update a single single

I have like 9 fields then there a math formula i need to run and show the result on another field, is there a way to to this without using the AfterStateUpdate and duplicate the formula on each of the 9 fields and then update the value on the result field?
12 Replies
Dan Harrin
Dan Harrin16mo ago
do it the opposite way round instead of using a field, use a placeholder with dynamic content to display the result then use $get to get the values of the fields and return the result
tiago.pereira
tiago.pereira16mo ago
but if the fields are updated it the placeholder also update right now what i did was placed the formula inside re result field, with the afterstateupdated then on all other files did a $set to set the value to 0 on the result field and it will trigger the updated status again to recalculate
tiago.pereira
tiago.pereira16mo ago
all the fields on the 3 right fieldsets are the values used to calculate the total neg comission
tiago.pereira
tiago.pereira16mo ago
but its nor working i think when updating via set does not triger the afterstateupdated let me try with the label
Dan Harrin
Dan Harrin16mo ago
please send the code you tried with the Placeholder
tiago.pereira
tiago.pereira16mo ago
im still trying with place holder trying to search how how to make it dinamic
Dan Harrin
Dan Harrin16mo ago
content(fn ($get) => $get('field_name') + $get('field_name'))
tiago.pereira
tiago.pereira16mo ago
working now, just need to apply some css to make it look like a disabled field
tiago.pereira
tiago.pereira16mo ago
And its now done with placeholder
tiago.pereira
tiago.pereira16mo ago
thanks a lot but with the label i cant save this value do DB right?
Dan Harrin
Dan Harrin16mo ago
do it in an observer if this was a field, the user would have been able to change the value maliciously via javascript
tiago.pereira
tiago.pereira16mo ago
yes for this thats not a issue its a private application they will be digging for those workarounds, but its better that way anyway
Want results from more Discord servers?
Add your server