Page 1 of 1

UDT and calculation with LISE fields converted to numbers

Posted: Tue Aug 08, 2023 8:20 pm
by webform
I have a LISE Instance with fields containing numbers i want to add together.

I'm using an UDT and an Event Handler (PreItemSave) for the LISE Instance to save the result of the calculation. But it seems my LISE fields is not accepted as numbers. What am i doing wrong here?

My UDT:

Code: Select all

$item = $params['item_object'];

//Set Vars
$firstfield = (int)$item->firstfield;
$secondfield = (int)$item->secondfield;
$thirdfield = (int)$item->thirdfield;

//Calculate Total
$total = $firstfield + $secondfield + $thirdfield;

//Save To LISE Instance
$item->total = $total;

Re: UDT and calculation with LISE fields converted to numbers

Posted: Wed Aug 09, 2023 7:29 am
by webform
Oh! I found the solution at https://cmscanbesimple.org/blog/the-lise-module

Code: Select all

$firstfield = (int)(string)$item->firstfield;