diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 32f147917..32b4f974c 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -3049,16 +3049,21 @@ JS $oPage->SetCurrentTab(''); + // Static fields values for wizard helper serialization + $aWizardHelperStaticValues = []; + // Add as hidden inputs values that we want displayed if they're readonly if(isset($aExtraParams['forceFieldsSubmission'])){ $aExtraFlags = $aExtraParams['fieldsFlags'] ?? []; foreach ($aExtraParams['forceFieldsSubmission'] as $sAttCode) { if(FormHelper::GetAttributeFlagsForObject($this, $sAttCode, $aExtraFlags) & OPT_ATT_READONLY) { $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('attr_'.$sPrefix.$sAttCode, $this->Get($sAttCode))); + $aWizardHelperStaticValues[$sAttCode] = $this->Get($sAttCode); } } } - + $sWizardHelperStaticValues = json_encode($aWizardHelperStaticValues); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('class', $sClass)); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('transaction_id', $iTransactionId)); foreach ($aExtraParams as $sName => $value) { @@ -3101,6 +3106,7 @@ JS var oWizardHelper$sPrefix = new WizardHelper('$sClass', '$sPrefix', '$sLifecycleStateForWizardHelper'); oWizardHelper$sPrefix.SetFieldsMap($sJsonFieldsMap); oWizardHelper$sPrefix.SetFieldsCount($iFieldsCount); + oWizardHelper$sPrefix.SetStaticValues($sWizardHelperStaticValues); EOF ); $oPage->add_ready_script( diff --git a/js/wizardhelper.js b/js/wizardhelper.js index f34cf9e28..966412a01 100644 --- a/js/wizardhelper.js +++ b/js/wizardhelper.js @@ -65,6 +65,7 @@ function WizardHelper(sClass, sFormPrefix, sState, sInitialState, sStimulus) { 'm_aAllowedValuesRequested': [], 'm_oDefaultValue': {}, 'm_oAllowedValues': {}, + 'm_aStaticValues' : {}, 'm_iFieldsCount': 0, 'm_sFormPrefix': sFormPrefix, 'm_sState': sState, @@ -113,6 +114,18 @@ function WizardHelper(sClass, sFormPrefix, sState, sInitialState, sStimulus) { this.m_oData.m_oCurrentValues[sFieldName] = currentValue; }; + /** + * Set form object values for fields without field widget. + * + * @since 3.1 + * + * @param values + * @constructor + */ + this.SetStaticValues = function(values){ + this.m_oData.m_aStaticValues = values; + }; + this.SetReturnNotEditableFields = function (bReturnNotEditableFields) { this.m_oData.m_bReturnNotEditableFields = bReturnNotEditableFields; }; @@ -223,9 +236,15 @@ function WizardHelper(sClass, sFormPrefix, sState, sInitialState, sStimulus) { $('#wizStep'+G_iCurrentStep).unblock({fadeOut: 0}); }); }; - + this.UpdateCurrentValue = function (sFieldCode) { var $oField = $('#'+this.m_oData.m_oFieldsMap[sFieldCode]); + // Static values handling + if(this.m_oData.m_aStaticValues.hasOwnProperty(sFieldCode)){ + const value = this.m_oData.m_aStaticValues[sFieldCode]; + this.m_oData.m_oCurrentValues[sFieldCode] = value; + return value; + } $oField.trigger('update_value'); // Give the widget a chance to update its value (if it is aware of this event) var value = $oField.val(); if (value == '')