35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
class attr_float extends attr {
|
|
function getDBType() {
|
|
return "decimal(14,4)";
|
|
}
|
|
|
|
function render_input() {
|
|
|
|
$val = $this->getCurVal() + 0; // auto format trick
|
|
$val = number_format ($val, 3, '.','');
|
|
if ( $this->getAttrSetting('mand')) {
|
|
return '<input id="' . $this->attr_name . '" type="text" name="' . $this->attr_name . '" value="' .$val . '" class="form-control" required="required">';
|
|
} else {
|
|
return '<input id="' . $this->attr_name . '" type="text" name="' . $this->attr_name . '" value="' .$val . '" class="form-control">';
|
|
}
|
|
}
|
|
|
|
function render_text( $crop = false ) {
|
|
if ( !$this->getCurVal() ) return '0';
|
|
|
|
$dec = 2;
|
|
$val = $this->getCurVal() + 0; // auto format trick
|
|
if ( $this->obj->attrs[$this->attr_name]['templ'] ) {
|
|
$val = $this->getCurVal() + 0; // auto format trick
|
|
return floatval($val);
|
|
}
|
|
|
|
|
|
return number_format ($val, $dec, '.','');
|
|
}
|
|
|
|
}
|
|
|
|
?>
|