Hide extra vars with no value #2486

This commit is contained in:
Kijin Sung 2025-02-15 21:49:36 +09:00
parent 7d6565766a
commit 4bf4aca762
4 changed files with 24 additions and 4 deletions

View file

@ -22,8 +22,10 @@
{@ $_extra_vars = $oDocument->getExtraVars(); }
<dl class="xv">
<!--@foreach($_extra_vars as $key => $val)-->
<dt>{$val->name}</dt>
<dd>{$val->getValueHTML()}</dd>
<!--@if($val->hasValue())-->
<dt>{$val->name}</dt>
<dd>{$val->getValueHTML()}</dd>
<!--@end-->
<!--@end-->
</dl>
<!--@end-->

View file

@ -22,7 +22,7 @@
<!-- Extra Output -->
<div class="exOut" cond="$oDocument->isExtraVarsExists() && $oDocument->isAccessible()">
<table border="1" cellspacing="0" summary="Extra Form Output">
<tr loop="$oDocument->getExtraVars() => $key,$val">
<tr loop="$oDocument->getExtraVars() => $key,$val" cond="$val->hasValue()">
<th scope="row">{$val->name}</th>
<td>{$val->getValueHTML()}&nbsp;</td>
</tr>

View file

@ -26,7 +26,7 @@
<!-- Extra Output -->
<div class="exOut" cond="$oDocument->isExtraVarsExists() && $oDocument->isAccessible()">
<table border="1" cellspacing="0" summary="Extra Form Output">
<tr loop="$oDocument->getExtraVars() => $key,$val">
<tr loop="$oDocument->getExtraVars() => $key,$val" cond="$val->hasValue()">
<th scope="row">{$val->name}</th>
<td>{$val->getValueHTML()}&nbsp;</td>
</tr>

View file

@ -121,6 +121,24 @@ class Value
$this->value = $value;
}
/**
* Check if this extra variable has a value.
*
* @return bool
*/
public function hasValue(): bool
{
$value = self::_getTypeValue($this->type, $this->value);
if ($value === null || $value === '' || (is_array($value) && !count($value)))
{
return false;
}
else
{
return true;
}
}
/**
* Get the raw value.
*