N°9223 - Portal - AttributeExternalKey or AttributeEnum are not displayed after adding a link.#802
Conversation
…ayed after adding a link.
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where AttributeExternalKey and AttributeEnum fields were not being displayed after adding a link in the portal. The issue was caused by a mismatch between the data structure returned by GetInformationForLinkedSetAsJsonAction and the structure expected by the JavaScript/Twig templates that consume this data.
Changes:
- Updated the attribute data structure in
GetInformationForLinkedSetAsJsonActionto match the expected format used by portal templates and thePrepareObjectInformationmethod - Renamed
att_codetoattribute_codeandvaluetovalue_htmlfor consistency with the rest of the codebase - Added metadata fields (
object_class,object_id,prefix,attribute_type) required by the JavaScript consumers
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'css_inline' => $oFieldOutput->GetCss(), | ||
| 'js_inline' => $oFieldOutput->GetJs(), |
There was a problem hiding this comment.
The variable $oFieldOutput is used here but it's only defined inside the if block on line 1391-1395. When $sFieldRendererClass is null, $oFieldOutput will be undefined, causing a fatal error. The css_inline and js_inline properties should only be set when $oFieldOutput is available, similar to how it's done in BsLinkedSetFieldRenderer::PrepareItem (lines 880-887 in sources/Renderer/Bootstrap/FieldRenderer/BsLinkedSetFieldRenderer.php).
| $aObjectData['attributes']['lnk__'.$sAttCode] = [ | ||
| 'att_code' => $sAttCode, | ||
| 'value' => $sValue, | ||
| 'object_class' => $sLinkClass, | ||
| 'object_id' => $oNewLink->GetKey(), | ||
| 'prefix' => 'lnk__', | ||
| 'attribute_code' => $sAttCode, | ||
| 'attribute_type' => get_class($oAttDef), | ||
| 'value_html' => $sValue, | ||
| 'css_inline' => $oFieldOutput->GetCss(), | ||
| 'js_inline' => $oFieldOutput->GetJs(), | ||
| ]; |
There was a problem hiding this comment.
The data structure is missing the 'value_raw' field which is present in both PrepareObjectInformation (line 1462) and BsLinkedSetFieldRenderer::PrepareItem (line 866 in sources/Renderer/Bootstrap/FieldRenderer/BsLinkedSetFieldRenderer.php). For consistency and to maintain the same data structure across similar methods, 'value_raw' should be included here as well, following the same exclusion logic based on ApplicationHelper::GetAttDefClassesToExcludeFromMarkupMetadataRawValue().
internal