From e2b6453a96199abdb466e4dca57046ab45d8b3dd Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 5 Oct 2018 10:00:12 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#718 FieldtypeFloat float typecast in getPrecision() method --- wire/modules/Fieldtype/FieldtypeFloat.module | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wire/modules/Fieldtype/FieldtypeFloat.module b/wire/modules/Fieldtype/FieldtypeFloat.module index e018db07..c650a8d0 100644 --- a/wire/modules/Fieldtype/FieldtypeFloat.module +++ b/wire/modules/Fieldtype/FieldtypeFloat.module @@ -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');