Advanced Search: Fix ExternalFields allowed values

SVN:trunk[5668]
This commit is contained in:
Eric Espié
2018-04-13 15:27:00 +00:00
parent 9d5ab75dbd
commit ec2aadb7cf
2 changed files with 27 additions and 5 deletions

View File

@@ -746,10 +746,30 @@ class ScalarExpression extends UnaryExpression
{
switch (true)
{
case ($oAttDef instanceof AttributeExternalField):
try
{
if ($this->GetValue() == 0)
{
$aValue['label'] = Dict::S('UI:UndefinedObject');
}
else
{
/** @var AttributeExternalKey $oAttDef */
$sTarget = $oAttDef->GetFinalAttDef()->GetTargetClass();
$oObj = MetaModel::GetObject($sTarget, $this->GetValue());
$aValue['label'] = $oObj->Get("friendlyname");
}
}
catch (Exception $e)
{
IssueLog::Error($e->getMessage());
}
break;
case $oAttDef->IsExternalKey():
try
{
if ($this->GetValue() == 0)
{
$aValue['label'] = Dict::S('UI:UndefinedObject');

View File

@@ -429,10 +429,12 @@ class SearchForm
}
if ($oAttrDef instanceof AttributeExternalField)
{
// Let's propose every existing value
$oValSetDef = new ValueSetObjects('SELECT '.$sTargetClass);
$aAllowedValues = $oValSetDef->GetValues(array());
return array('values' => $aAllowedValues, 'count' => count($aAllowedValues));
$aAllowedValues = array();
while ($oObject = $oSet->Fetch())
{
$aAllowedValues[$oObject->GetKey()] = $oObject->GetName();
}
return array('values' => $aAllowedValues, 'count' => $iCount);
}
}
else