mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 09:59: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)
|
||||
return $infos['value'];
|
||||
$units = $this -> getUnits();
|
||||
if ($units) {
|
||||
foreach($units as $sill => $label) {
|
||||
if ($infos['value'] >= $sill) {
|
||||
$infos['valueWithUnit'] = $this -> formatNumber($infos['value']/$sill);
|
||||
$infos['unitSill'] = $sill;
|
||||
$infos['unitLabel'] = $label;
|
||||
break;
|
||||
}
|
||||
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) {
|
||||
if ($infos['value'] >= $sill) {
|
||||
$infos['valueWithUnit'] = $this -> formatNumber($infos['value']/$sill);
|
||||
$infos['unitSill'] = $sill;
|
||||
$infos['unitLabel'] = $label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $infos;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{$noValueTxt|escape:"htmlall"}
|
||||
{/if}
|
||||
{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"}'/>
|
||||
<select name='{$attr_name|escape:"htmlall"}_unitFact[]' class='LSform LSformElement_valueWithUnit'>
|
||||
{html_options options=$units selected=$values_and_units[$value].unitSill}
|
||||
|
|
Loading…
Reference in a new issue