An error has occurred with a calculated field - please inform the web-site owner.

sales2010

Well-Known Member
Hello,

In some forms that contain calc elements i see this notice:

"Notice: An error has occurred with a calculated field - please inform the web-site owner."

I verified the code and doesn't seems to be wrong, i get the values. For example, i don't understand what is wrong with this syntax:

Code:
$db = JFactory::getDBO();
$db->setQuery("select MAX(id) +1 from contracte_info_generale");
$theid = $db->loadResult();
return 'TMAPFA nr '.$theid;

I also tried this code, same problem:

Code:
$db =JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('MAX(id) +1')
->from('contracte_info_generale');
$db->setQuery($query);
$theid = $db->loadResult();
return 'TMAPFA nr '.$theid;

Thank you
 
Turn on Joomla or Fabrik debugging in global settings and you will get a more informative error message.
 
Thank you, now i see this message:

Code:
Eval exception : serie_nr_contract::getDefaultValue() : TMAPDF nr 4572286 : syntax error, unexpected 'nr' (T_STRING)

Still don't understand why 'nr' is unexpected....
 
As you picked up in your second example, method names in php are case sensitive. So your code should be:

PHP:
$db = JFactory::getDbo();
$db->setQuery("select MAX(id) +1 from contracte_info_generale");
$theid = $db->loadResult();
return 'TMAPFA nr '.$theid;

From the error message it looks like your code worked and returned the string 'TMAPDF nr 4572286' and Fabrik then tried to eval this string.

Can you upload screenshots of your serie_nr_contract element definition?

Thx.

S
 
What is confusing me is why the error message is referring to method "getDefaultValue()" (in the calc element code calc.php) rather than "_getV()" (which is what I get when I try to create an error). Can you let me know your List View and Access settings?

I am not sure if it will help you further, but you could also try setting Joomla Global Configuration / Server / Error Reporting to maximum and see if you get any additional php messages displayed.

Thx.

S
 
This is what i see with Reporting set to maximum:

Code:
Parse error: syntax error, unexpected 'nr' (T_STRING) in C:\xampp\htdocs\aplicatii\plugins\fabrik_element\calc\calc.php(45) : eval()'d code on line 1
 
I am still tryingto work out why you are getting this error in getDefaultValue rather than _getV. Do you get the same error on adding a new field or editing an existing field? Is this in a repeat group?

Thx.
 
No, is not in a repeat group. I have other calc element in the same form, but i don't see any other notice displayed
 
The message it displayed also if you have e.g. a php validation (with wrong code) on an other element (this is what I have tested; maybe also a condition in validation or in a form plugin - I didn't test this).

So the message is not related to code in calc elements only but to "calculated fields".
 
I am still unclear why:

1. It is eval'ing the results of the calc field (again).
2. It is giving an error in getDefaultValue rather than _getV.

I think that if we could understand the reasons for these, we would be closer to solving this.

Perhaps sales2000 could check the Default boxes for ALL his fields and see if any have eval set to yes.

S
 
I think i've got something:
error message with getDefaultValue is created in calc.php inside
if ($element->eval == '1')
but a normal calc element doesn't have an eval (or default).

I assume this calc element is an old one (upgraded from fabrik2.0) or a modified e.g. field element (which was defined with default+eval).
sales2010: is this possible?
if yes, can you check this element in #_fabrik_elements if column eval=1 (+ set it to 0 and test again)?

I can provoke the getDefaultValue error by setting eval=1 via phpMyAdmin.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top