BUG calculated field

taubes

Member
Hi

I found a bug in an a calculated field. The correct calculated field is shown but the value is not saved
when if have "if" condition in the calculated_field_function: if ($parameters_ar('field_x') == 1) { ... set return value ... } that references a field with the EDIT permission 'YES but disabled'

Strangely the auto calculated value is actually shown in the form but it is not saved.

This was reproducible in DaDaBIK 9 (enterprise) and 10.6 (platinum)

PHP Version: 7.3.27-1~deb10u1
mysql version: 5.5.5-10.3.27-MariaDB-0+deb10u1
Web server: nginx/1.18.0
Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15

Best

Stefan
 

eugenio

Administrator
Staff member
Hello Stefan,
disabled fields cannot be used as parameters for calculated field, this is remarked in the manual:
"If you need to use a field value, the correspondent field cannot be disabled in the edit form"

You are right, though, that if the value is calculated in the form this can lead the user to the wrong assumption that the value will be correctly calculated after the form submission. I will make it clearer in the manual.

Best,
 

taubes

Member
Hi Eugenio,

Thanks for the quick reply. It was not clear that another visible but disabled field cannot be referenced from an enabled field, especially since the custom function correctly processes the value from that enabled field correctly. Values that did not underwent the "bad if statement" were processed fine and saved.

Some kind of error would be helpful as it can lead to bad errors in the data input.

As always thanks

Stefan
 

eugenio

Administrator
Staff member
Hello,
I will add more details to the documentation but throwing an error in all these cases might be not trivial.

Best,
 
Top