mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 19:18:44 +02:00
N°984 Portal: Fix autocomplete field reset when changing value of parent field in request templates.
SVN:trunk[5261]
This commit is contained in:
@@ -19,8 +19,12 @@
|
||||
|
||||
namespace Combodo\iTop\Form\Field;
|
||||
|
||||
use \Closure;
|
||||
use \DBSearch;
|
||||
use Closure;
|
||||
use DBSearch;
|
||||
use DBObjectSet;
|
||||
use BinaryExpression;
|
||||
use FieldExpression;
|
||||
use ScalarExpression;
|
||||
use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
|
||||
|
||||
/**
|
||||
@@ -148,4 +152,26 @@ class SelectObjectField extends Field
|
||||
{
|
||||
return $this->sSearchEndpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets current value is not among allowed ones.
|
||||
* By default, reset is done ONLY when the field is not read-only.
|
||||
*
|
||||
* @param boolean $bAlways Set to true to verify even when the field is read-only.
|
||||
*/
|
||||
public function VerifyCurrentValue($bAlways = false)
|
||||
{
|
||||
if(!$this->GetReadOnly() || $bAlways)
|
||||
{
|
||||
$oValuesScope = $this->GetSearch()->DeepClone();
|
||||
$oBinaryExp = new BinaryExpression(new FieldExpression('id', $oValuesScope->GetClassAlias()), '=', new ScalarExpression($this->currentValue));
|
||||
$oValuesScope->AddConditionExpression($oBinaryExp);
|
||||
$oValuesSet = new DBObjectSet($oValuesScope);
|
||||
|
||||
if($oValuesSet->Count() === 0)
|
||||
{
|
||||
$this->currentValue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user