@@ -3266,13 +3266,16 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar
32663266 if (array_key_exists ($ sAttCode , $ aExpectedAttributes )) {
32673267 $ iExpectCode = $ aExpectedAttributes [$ sAttCode ];
32683268
3269+ $ bIsPrompt =false ;
3270+ $ aAttrib = [];
3271+ $ oAttDef = MetaModel::GetAttributeDef ($ sClass , $ sAttCode );
32693272 // Prompt for an attribute if
32703273 // - the attribute must be changed or must be displayed to the user for confirmation
32713274 // - or the field is mandatory and currently empty
32723275 if (($ iExpectCode & (OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT )) ||
32733276 (($ iExpectCode & OPT_ATT_MANDATORY ) && (false === $ this ->HasAValue ($ sAttCode )))) {
3277+ $ bIsPrompt = true ;
32743278 $ aArgs = array ('this ' => $ this );
3275- $ oAttDef = MetaModel::GetAttributeDef ($ sClass , $ sAttCode );
32763279 // If the field is mandatory, set it to the only possible value
32773280 if ((!$ oAttDef ->IsNullAllowed ()) || ($ iExpectCode & OPT_ATT_MANDATORY )) {
32783281 if ($ oAttDef ->IsExternalKey ()) {
@@ -3283,8 +3286,7 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar
32833286 $ oRemoteObj = $ oAllowedValues ->Fetch ();
32843287 $ this ->Set ($ sAttCode , $ oRemoteObj ->GetKey ());
32853288 }
3286- } else
3287- {
3289+ } else {
32883290 if ($ oAttDef instanceof \AttributeCaseLog) {
32893291 // Add JS files for display caselog
32903292 // Dummy collapsible section created in order to get JS files
@@ -3294,8 +3296,7 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar
32943296 }
32953297 }
32963298 $ aAllowedValues = MetaModel::GetAllowedValues_att ($ sClass , $ sAttCode , $ aArgs );
3297- if (is_array ($ aAllowedValues ) && count ($ aAllowedValues ) == 1 )
3298- {
3299+ if (is_array ($ aAllowedValues ) && count ($ aAllowedValues ) == 1 ) {
32993300 $ aValues = array_keys ($ aAllowedValues );
33003301 $ this ->Set ($ sAttCode , $ aValues [0 ]);
33013302 }
@@ -3316,15 +3317,22 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar
33163317 $ sHTMLValue = cmdbAbstractObject::GetFormElementForField ($ oPage , $ sClass , $ sAttCode , $ oAttDef ,
33173318 $ value , $ sDisplayValue , $ sInputId , '' , $ iExpectCode ,
33183319 $ aArgs , true , $ sInputType );
3320+ $ aAttrib = array (
3321+ 'label ' => '<span> ' .$ oAttDef ->GetLabel ().'</span> ' ,
3322+ 'value ' => "<span id= \"field_att_ $ iFieldIndex \"> $ sHTMLValue</span> " ,
3323+ );
3324+ }
3325+ if (($ iExpectCode & OPT_ATT_READONLY ) ){
3326+ $ bIsPrompt = true ;
3327+ $ sHTMLValue = $ this ->GetAsHTML ($ sAttCode );
33193328 $ aAttrib = array (
33203329 'label ' => '<span> ' .$ oAttDef ->GetLabel ().'</span> ' ,
33213330 'value ' => "<span id= \"field_att_ $ iFieldIndex \"> $ sHTMLValue</span> " ,
33223331 );
3323-
3332+ }
3333+ if ($ bIsPrompt ) {
33243334 //add attrib for data-attribute
33253335 // Prepare metadata attributes
3326- $ sAttCode = $ oAttDef ->GetCode ();
3327- $ oAttDef = MetaModel::GetAttributeDef ($ sClass , $ sAttCode );
33283336 $ sAttDefClass = get_class ($ oAttDef );
33293337 $ sAttLabel = MetaModel::GetLabel ($ sClass , $ sAttCode );
33303338
0 commit comments