Skip to main content
9 events
when toggle format what by license comment
Oct 4, 2013 at 17:06 comment added danielesus Eureka. Not perfect, but works. Went back to the original code, changed last line. Still getting Warning on submission, but the calculation is working and shows up properly, even subtracted another variable $coupon. I decided to try grouping variables using normal math formulas using "+" between each. $entity_field[0]['value'] = (($howmany*$price1) + ($howmany*$price2)) - $coupon; Now that the variables are not being multiplied by a null value and there is value for one pair, I get the results, even if I still get the Warning. I guess I can turn off those. Thanks very much for your help.
Oct 4, 2013 at 16:37 comment added danielesus On form submission, get a WSOD with Fatal error on line 1: Fatal error: Can't use function return value in write context in /home/content/67/10793667/html/sites/all/modules/computed_field/computed_field.module(466) : eval()'d code on line 1
Oct 4, 2013 at 15:54 history edited Neo CC BY-SA 3.0
added 451 characters in body
Oct 4, 2013 at 15:50 comment added Neo ok I think I figured out the issue. the issue lies in the two array_pop s. In case of an empty field, the first array_pop returns null. And hence the second one gets null as parameter. Updated my answer accordingly.
Oct 4, 2013 at 15:01 comment added danielesus Same results, same Warning. Works fine with just 2 fields, computed value - great. As soon as I add a 3rd, get the error and 0 value.
Oct 4, 2013 at 14:41 comment added Neo modified the code. Please see if this works.
Oct 4, 2013 at 14:40 history edited Neo CC BY-SA 3.0
Improved logic and added a few more options
Oct 4, 2013 at 14:32 comment added danielesus Hi Neo, thanks so much for your quickly reply. Been testing almost immediately, getting the same results as before, same Warning on empty fields. Using the code you gave, with only 2 fields (e.g., $howmany and $price1) works as before with computed value appearing correctly. I get the same error when I add a 3rd variable that is an empty field - and the results shows 0, most likely due the multiplication with empty field.
Oct 4, 2013 at 13:55 history answered Neo CC BY-SA 3.0