mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 11:52:59 +01:00
LSattr_html::valueWithUnit: fix handling zero value
This commit is contained in:
parent
dff2aa8b46
commit
d637a570f1
2 changed files with 18 additions and 9 deletions
|
@ -90,7 +90,16 @@ class LSformElement_valueWithUnit extends LSformElement {
|
||||||
if (!$details)
|
if (!$details)
|
||||||
return $infos['value'];
|
return $infos['value'];
|
||||||
$units = $this -> getUnits();
|
$units = $this -> getUnits();
|
||||||
if ($units) {
|
if (!$units)
|
||||||
|
return $infos;
|
||||||
|
if ($infos['value'] == 0) {
|
||||||
|
ksort($units);
|
||||||
|
$infos['valueWithUnit'] = $this -> formatNumber(0);
|
||||||
|
$infos['unitSill'] = key($units);
|
||||||
|
$infos['unitLabel'] = $units[$infos['unitSill']];
|
||||||
|
return $infos;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($units as $sill => $label) {
|
foreach($units as $sill => $label) {
|
||||||
if ($infos['value'] >= $sill) {
|
if ($infos['value'] >= $sill) {
|
||||||
$infos['valueWithUnit'] = $this -> formatNumber($infos['value']/$sill);
|
$infos['valueWithUnit'] = $this -> formatNumber($infos['value']/$sill);
|
||||||
|
@ -99,7 +108,7 @@ class LSformElement_valueWithUnit extends LSformElement {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $infos;
|
return $infos;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{$noValueTxt|escape:"htmlall"}
|
{$noValueTxt|escape:"htmlall"}
|
||||||
{/if}
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
{if $values_and_units[$value].valueWithUnit || !$values_and_units[$value]}
|
{if isset($values_and_units[$value].valueWithUnit) || !$values_and_units[$value]}
|
||||||
<input name='{$attr_name|escape:"htmlall"}_valueWithUnit[]' type=text class='LSformElement_valueWithUnit' value='{$values_and_units[$value].valueWithUnit|escape:"htmlall"}'/>
|
<input name='{$attr_name|escape:"htmlall"}_valueWithUnit[]' type=text class='LSformElement_valueWithUnit' value='{$values_and_units[$value].valueWithUnit|escape:"htmlall"}'/>
|
||||||
<select name='{$attr_name|escape:"htmlall"}_unitFact[]' class='LSform LSformElement_valueWithUnit'>
|
<select name='{$attr_name|escape:"htmlall"}_unitFact[]' class='LSform LSformElement_valueWithUnit'>
|
||||||
{html_options options=$units selected=$values_and_units[$value].unitSill}
|
{html_options options=$units selected=$values_and_units[$value].unitSill}
|
||||||
|
|
Loading…
Reference in a new issue