diff --git a/src/includes/class/class.LSformElement_valueWithUnit.php b/src/includes/class/class.LSformElement_valueWithUnit.php
index 9f3aa681..0b140396 100644
--- a/src/includes/class/class.LSformElement_valueWithUnit.php
+++ b/src/includes/class/class.LSformElement_valueWithUnit.php
@@ -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;
diff --git a/src/templates/default/LSformElement_valueWithUnit_field.tpl b/src/templates/default/LSformElement_valueWithUnit_field.tpl
index 87f26c17..77b3cb4e 100644
--- a/src/templates/default/LSformElement_valueWithUnit_field.tpl
+++ b/src/templates/default/LSformElement_valueWithUnit_field.tpl
@@ -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]}