-
- 502 Posts
Would it be possible to make the precision of floats configurable in the next version? It would probably be best specified as part of the eform tag. Perhaps the types "float_n" could be implemented. For example, float_2, float_4, etc. Instead of checking the whole type string in the code, just check to see if it starts with "float" and then split() to get the precision. "float" could imply "float_2" to be backwards compatible.
I am working on an application where I need 10 decimal places, and I don’t like to modify eform directly.
Thanks, Andy
Line 271 of eform.inc.php
# format report fields
foreach($fields as $name => $value) {
$fld = $formats[$name];
if ($fld) {
$datatype = $fld[2];
switch ($datatype) {
case "integer":
$value = number_format($value);
break;
case "float":
$value = number_format($value, 2, '.', ',');
break;
Sure. Just make that a variable, say $precision, and in the snippet code add (just before the eform params comment)
// float precision
precision => isset($precision)? $precision:2,