N.981 Regression introduced in [r4692]. It make sense to preserve the existing value... excepted when reloading some form elements (filtering depending on fields that have just been touched by the user).

SVN:trunk[4895]
This commit is contained in:
Romain Quetiez
2017-09-05 15:44:48 +00:00
parent 051d68c902
commit ac04aa3359
2 changed files with 25 additions and 4 deletions

View File

@@ -1763,8 +1763,22 @@ EOF
*/
return $sHtml;
}
public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array())
/**
* @param $oPage
* @param $sClass
* @param $sAttCode
* @param $oAttDef
* @param string $value
* @param string $sDisplayValue
* @param string $iId
* @param string $sNameSuffix
* @param int $iFlags
* @param array $aArgs
* @param bool $bPreserveCurrentValue Preserve the current value even if not allowed
* @return string
*/
public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true)
{
static $iInputId = 0;
$sFieldPrefix = '';
@@ -2026,7 +2040,14 @@ EOF
$aEventsList[] ='validate';
$aEventsList[] ='change';
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs, '', $value);
if ($bPreserveCurrentValue)
{
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs, '', $value);
}
else
{
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs);
}
$sFieldName = $sFieldPrefix.$sAttCode.$sNameSuffix;
$aExtKeyParams = $aArgs;
$aExtKeyParams['iFieldSize'] = $oAttDef->GetMaxSize();