N°5784 - PHP 8.0: Fix mandatory attribute not visible in transition form due to bad emptiness test (#379)

* N°5784 - PHP 8.0: Fix mandatory attribute not visible in transition form due to bad emptiness test

* N°5784 - Rework AttributeDefinition::HasAValue() implementation after code review

* N°5784 - Add unit test
This commit is contained in:
Molkobain
2023-03-07 10:16:14 +01:00
committed by GitHub
parent 03fb78c38c
commit a34274b883
4 changed files with 338 additions and 2 deletions

View File

@@ -4001,6 +4001,20 @@ abstract class DBObject implements iDisplay
return $bSuccess;
}
/**
* @param string $sAttCode
*
* @return bool True if $sAttCode has an actual value set, false is the attribute remains "empty"
* @throws \ArchivedObjectException
* @throws \CoreException
* @since 3.0.3, 3.1.0 N°5784
*/
public function HasAValue(string $sAttCode): bool
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
return $oAttDef->HasAValue($this->Get($sAttCode));
}
/**
* Helper to recover the default value (aka when an object is being created)
* Suitable for use as a lifecycle action