- 🇬🇧United Kingdom mylocaltrades
So I have finally got around to working on this issue again and now have the solution in case it helps anyone else.
The computed twig used before php8:
sockets:
'#type': textfield
'#title': 'How many sockets would you like?'
socketcost:
'#type': hidden
'#title': 'socket cost'
'#default_value': '65.00'
'#prepopulate': true
total_cost:
'#type': computed_twig
'#title': 'Total cost'
'#title_display': invisible
'#template': '
£{{ (data.sockets * data.socketcost) }}excluding VAT'
'#ajax': trueThis above would multiply the amount of sockets by each individual socket cost. I can confirm this does not work in PHP8>
Below is how it now works in PHP8> - I use the number field instead of the textfield and the value field for the individual cost price:
sockets:
'#type': number
'#title': 'How many sockets would you like?'
socketcost:
'#type': value
'#title': socketcost
'#value': '65'
balance:
'#type': computed_twig
'#title': 'Total cost'
'#mode': text
'#template': '{{ (data.sockets|number_format * data.socketcost) }}
'#whitespace': trim
'#ajax': true