mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +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,16 +90,25 @@ 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)
|
||||||
foreach($units as $sill => $label) {
|
return $infos;
|
||||||
if ($infos['value'] >= $sill) {
|
if ($infos['value'] == 0) {
|
||||||
$infos['valueWithUnit'] = $this -> formatNumber($infos['value']/$sill);
|
ksort($units);
|
||||||
$infos['unitSill'] = $sill;
|
$infos['valueWithUnit'] = $this -> formatNumber(0);
|
||||||
$infos['unitLabel'] = $label;
|
$infos['unitSill'] = key($units);
|
||||||
break;
|
$infos['unitLabel'] = $units[$infos['unitSill']];
|
||||||
}
|
return $infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($units as $sill => $label) {
|
||||||
|
if ($infos['value'] >= $sill) {
|
||||||
|
$infos['valueWithUnit'] = $this -> formatNumber($infos['value']/$sill);
|
||||||
|
$infos['unitSill'] = $sill;
|
||||||
|
$infos['unitLabel'] = $label;
|
||||||
|
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