Javascript based calculated field algorithm builder.
With this algorithm the user can implement it's own algorithm directly in
javascript and directly inside the form definition.
The syntax is as follows:
<fd:value type="javascript" triggers="items,price,discount">
var price = parent.lookupWidget('price').getValue();
var items = parent.lookupWidget('items').getValue();
var discount = parent.lookupWidget('discount').getValue();
if (discount == 'completelyfree') return 0;
var total = price * items;
if (discount == 'halfprice') return total / 2;
return total;
</fd:value>
From inside the javascript function the following objects are accessible:
form
The form object.
parent
The parent widget. This is very useful in repeaters, since the parent is the repeater row.
cocoon and other FOM objects
This are accessible only when flowscript is in use (see bug COCOON-1804)
As you can see, the function must return the calculated value, and not set this
directly in the widget. This way the value can be converted correctly if needed.