N°6414 Replace SelectObjectField::VerifyCurrentValue by ResetCurrentValueIfNotAmongAllowedValues

This commit is contained in:
Pierre Goiffon
2023-06-14 15:09:16 +02:00
parent b46d4db8ff
commit f40674ec85
2 changed files with 23 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
use ContextTag;
use DBObjectSet;
use DBSearch;
use DeprecatedCallsLog;
use FieldExpression;
use MetaModel;
use ScalarExpression;
@@ -281,8 +282,28 @@ class SelectObjectField extends Field
* @param boolean $bAlways Set to true to verify even when the field is read-only.
*
* @throws \CoreException
*
* @deprecated 3.1.0 N°6414 use ResetCurrentValueIfNotAmongAllowedValues instead
*/
public function VerifyCurrentValue(bool $bAlways = false) {
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('3.1.0 N°6414 use ResetCurrentValueIfNotAmongAllowedValues instead');
$this->ResetCurrentValueIfNotAmongAllowedValues($bAlways);
}
/**
* Resets current value if not among allowed ones.
* By default, reset is done ONLY when the field is not read-only.
*
* Called conditionally from {@see \Combodo\iTop\Portal\Form\ObjectFormManager::Build}
* This check isn't in the Validate method as we don't want to check for untouched and invalid values (value was set in the past, it is now invalid, but the user didn't change it)
*
* @param boolean $bAlways Set to true to verify even when the field is read-only.
*
* @throws \CoreException
*
* @since 3.1.0 N°6414 replaces VerifyCurrentValue$
*/
public function ResetCurrentValueIfNotAmongAllowedValues(bool $bAlways = false) {
if (!$this->GetReadOnly() || $bAlways) {
$oValuesSet = $this->GetObjectsSet();