diff --git a/core/model/fieldtypes/Float.php b/core/model/fieldtypes/Float.php index 9834e6fd6..b00caac20 100644 --- a/core/model/fieldtypes/Float.php +++ b/core/model/fieldtypes/Float.php @@ -12,8 +12,36 @@ */ class Float extends DBField { + /** + * Allows for setting the digits before decimal point + * e.g. a value of 7 can be -99999.99 + * + * @var int + */ + protected $countTotalDigits; + + /** + * Allows for setting the digits before decimal point + * e.g. a value of 4 can be -999.9999 + * + * @var int + */ + protected $countDigitsAfterDecimal; + + function __construct($name, $countTotalDigits, $countDigitsAfterDecimal) { + $this->countTotalDigits = $countTotalDigits; + $this->countDigitsAfterDecimal = $countDigitsAfterDecimal; + + parent::__construct($name); + } + function requireField() { - DB::requireField($this->tableName, $this->name, "float"); + if($this->countTotalDigits && $this->countDigitsAfterDecimal) { + $sql = "float({$this->countTotalDigits},{$this->countDigitsAfterDecimal})"; + } else { + $sql = "float"; + } + DB::requireField($this->tableName, $this->name, $sql); } function Nice() {