mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°6414 Replace SelectObjectField::VerifyCurrentValue by ResetCurrentValueIfNotAmongAllowedValues
This commit is contained in:
@@ -783,7 +783,7 @@ class ObjectFormManager extends FormManager
|
|||||||
{
|
{
|
||||||
// Note: We can't do this in AttributeExternalKey::MakeFormField() in the Field::SetOnFinalizeCallback() because at this point we have no information about the portal scope and ignore_silos flag, hence it always applies silos.
|
// Note: We can't do this in AttributeExternalKey::MakeFormField() in the Field::SetOnFinalizeCallback() because at this point we have no information about the portal scope and ignore_silos flag, hence it always applies silos.
|
||||||
// As a workaround we have to manually check if the field's current value is among the scope
|
// As a workaround we have to manually check if the field's current value is among the scope
|
||||||
$oField->VerifyCurrentValue();
|
$oField->ResetCurrentValueIfNotAmongAllowedValues();
|
||||||
}
|
}
|
||||||
// - Field that require processing on their subfields
|
// - Field that require processing on their subfields
|
||||||
if (in_array(get_class($oField), array('Combodo\\iTop\\Form\\Field\\SubFormField')))
|
if (in_array(get_class($oField), array('Combodo\\iTop\\Form\\Field\\SubFormField')))
|
||||||
@@ -820,7 +820,7 @@ class ObjectFormManager extends FormManager
|
|||||||
if (in_array(get_class($oCustomField), array('Combodo\\iTop\\Form\\Field\\SelectObjectField')))
|
if (in_array(get_class($oCustomField), array('Combodo\\iTop\\Form\\Field\\SelectObjectField')))
|
||||||
{
|
{
|
||||||
/** @var \Combodo\iTop\Form\Field\SelectObjectField $oCustomField */
|
/** @var \Combodo\iTop\Form\Field\SelectObjectField $oCustomField */
|
||||||
$oCustomField->VerifyCurrentValue();
|
$oCustomField->ResetCurrentValueIfNotAmongAllowedValues();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
|
|||||||
use ContextTag;
|
use ContextTag;
|
||||||
use DBObjectSet;
|
use DBObjectSet;
|
||||||
use DBSearch;
|
use DBSearch;
|
||||||
|
use DeprecatedCallsLog;
|
||||||
use FieldExpression;
|
use FieldExpression;
|
||||||
use MetaModel;
|
use MetaModel;
|
||||||
use ScalarExpression;
|
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.
|
* @param boolean $bAlways Set to true to verify even when the field is read-only.
|
||||||
*
|
*
|
||||||
* @throws \CoreException
|
* @throws \CoreException
|
||||||
|
*
|
||||||
|
* @deprecated 3.1.0 N°6414 use ResetCurrentValueIfNotAmongAllowedValues instead
|
||||||
*/
|
*/
|
||||||
public function VerifyCurrentValue(bool $bAlways = false) {
|
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) {
|
if (!$this->GetReadOnly() || $bAlways) {
|
||||||
$oValuesSet = $this->GetObjectsSet();
|
$oValuesSet = $this->GetObjectsSet();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user