1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-23 06:44:38 +02:00

Fix issue processwire/processwire-issues#718 FieldtypeFloat float typecast in getPrecision() method

This commit is contained in:
Ryan Cramer
2018-10-05 10:00:12 -04:00
parent 8e22bee1b5
commit e2b6453a96

View File

@@ -104,6 +104,7 @@ class FieldtypeFloat extends Fieldtype {
}
public static function getPrecision($value) {
$value = (float) $value;
$remainder = ceil($value) - $value;
$precision = strlen(ltrim($remainder, '0., '));
if(!$precision) $precision = 1;
@@ -121,6 +122,7 @@ class FieldtypeFloat extends Fieldtype {
if(is_null($field->precision)) $field->precision = 2;
/** @var InputfieldInteger $f */
$f = $this->modules->get('InputfieldInteger');
$f->attr('name', 'precision');
$f->label = $this->_('Number of decimal digits to round to');