-
Notifications
You must be signed in to change notification settings - Fork 284
N°6111 - Display in read-only mode a field in transition #750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3266,13 +3266,16 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar | |||||
| if (array_key_exists($sAttCode, $aExpectedAttributes)) { | ||||||
| $iExpectCode = $aExpectedAttributes[$sAttCode]; | ||||||
|
|
||||||
| $bIsPrompt=false; | ||||||
| $aAttrib = []; | ||||||
| $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); | ||||||
| // Prompt for an attribute if | ||||||
| // - the attribute must be changed or must be displayed to the user for confirmation | ||||||
| // - or the field is mandatory and currently empty | ||||||
| if (($iExpectCode & (OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT)) || | ||||||
| (($iExpectCode & OPT_ATT_MANDATORY) && (false === $this->HasAValue($sAttCode)))) { | ||||||
| $bIsPrompt = true; | ||||||
| $aArgs = array('this' => $this); | ||||||
| $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); | ||||||
| // If the field is mandatory, set it to the only possible value | ||||||
| if ((!$oAttDef->IsNullAllowed()) || ($iExpectCode & OPT_ATT_MANDATORY)) { | ||||||
| if ($oAttDef->IsExternalKey()) { | ||||||
|
|
@@ -3283,8 +3286,7 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar | |||||
| $oRemoteObj = $oAllowedValues->Fetch(); | ||||||
| $this->Set($sAttCode, $oRemoteObj->GetKey()); | ||||||
| } | ||||||
| } else | ||||||
| { | ||||||
| } else { | ||||||
| if ($oAttDef instanceof \AttributeCaseLog) { | ||||||
| // Add JS files for display caselog | ||||||
| // Dummy collapsible section created in order to get JS files | ||||||
|
|
@@ -3294,8 +3296,7 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar | |||||
| } | ||||||
| } | ||||||
| $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs); | ||||||
| if (is_array($aAllowedValues) && count($aAllowedValues) == 1) | ||||||
| { | ||||||
| if (is_array($aAllowedValues) && count($aAllowedValues) == 1) { | ||||||
| $aValues = array_keys($aAllowedValues); | ||||||
| $this->Set($sAttCode, $aValues[0]); | ||||||
| } | ||||||
|
|
@@ -3316,15 +3317,22 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar | |||||
| $sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, | ||||||
| $value, $sDisplayValue, $sInputId, '', $iExpectCode, | ||||||
| $aArgs, true, $sInputType); | ||||||
| $aAttrib = array( | ||||||
| 'label' => '<span>'.$oAttDef->GetLabel().'</span>', | ||||||
| 'value' => "<span id=\"field_att_$iFieldIndex\">$sHTMLValue</span>", | ||||||
| ); | ||||||
| } | ||||||
| if (($iExpectCode & OPT_ATT_READONLY) ){ | ||||||
|
||||||
| if (($iExpectCode & OPT_ATT_READONLY) ){ | |
| if (($iExpectCode & OPT_ATT_READONLY)) { |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after 'if' keyword. The codebase follows a consistent style of having a space between 'if' and the opening parenthesis, as seen on lines 3275, 3280, 3299, and throughout the file.
| if($bIsPrompt) { | |
| if ($bIsPrompt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic here has a potential issue. When a field has both MUSTCHANGE/MUSTPROMPT flags AND READONLY flags, the first block (lines 3275-3324) will execute and create an editable form field, but then the second block (lines 3325-3332) will overwrite $aAttrib with a readonly display. This means the READONLY flag takes precedence, which may not be the intended behavior. Consider using 'else if' instead of a separate 'if' to ensure mutual exclusivity between editable and readonly display modes.