class = 'FloatField'; $this->name = $name; $this->mDelimiter = $user->getDecimalMark(); } function localize() { global $user; $this->mDelimiter = $user->getDecimalMark(); } function setFormat($format) { $this->mFFormat = $format; } function setValue($value) { if (isset($this->mFFormat) && isset($value) && strlen($value)) { $value = str_replace($this->mDelimiter, '.', $value); $value = sprintf('%'.$this->mFFormat.'f', $value); $value = str_replace('.', $this->mDelimiter, $value); } $this->value = $value; } function setValueSafe($value) { // '.' to ',' , apply delimiter if (strlen($value) > 0) $this->value = str_replace('.', $this->mDelimiter, $value); } function getValueSafe() { // ',' to '.' if (strlen($this->value) > 0) return str_replace($this->mDelimiter, '.', $this->value); return null; } }