Content templates: support linking multiple-cardinality field widgets
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3554197. --> Reported by: [wim leers](https://www.drupal.org/user/99777) Related to !278 !679 >>> <h3 id="overview">Overview</h3> <p>Similar to <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3548395" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3548395</a></span>, the linker does not appear. Discovered in <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3554182" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3554182</a></span>, which itself was spawned by this Drupal CMS bug report: <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/drupal_cms/-/work_items/3552918" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/drupal_cms/-/work_items/3552918</a></span>.</p> <p><img src="https://www.drupal.org/files/issues/2025-10-24/type%3Darray%20prop%20no%20linker%20for%20field%20widget.png"><br> &#128070; no linker, despite suggestions being available &mdash; see <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3554182" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3554182</a></span>.</p> <p>Test by:</p> <ol> <li>instantiating a "Tags" test-only SDC provided by <code>canvas_test_sdc</code> since <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3554182" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3554182</a></span> </li><li>&hellip; on a content template for a node type that has an optional multiple-cardinality entity reference field, such as the typical <code>field_tags</code> field </li></ol> <p>Presumably, this is due to how it associates the linker with the field label, and multi-value field widgets appear to render the label differently.</p> <p>&#9888;&#65039; Note: this is arguably blocked on <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3546869" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3546869</a></span>, because until that happens, technically multiple-cardinality field widgets are not supported at all by Canvas yet!</p> <h3 id="root-cause">Root cause</h3> <p>Multi-value field widgets don't render a standard field label. Instead, the label is rendered as an <code>&amp;lt;h4&amp;gt;</code> inside a table header. The existing linker logic only attached to elements with <code>#title_display</code>, which doesn't apply to this table header structure.</p> <h3 id="proposed-resolution">Proposed resolution</h3> <p>Add handling in <code>canvas_stark_preprocess_field_multiple_value_form()</code> to render the linker alongside the <code>&amp;lt;h4&amp;gt;</code> in the table header when <code>#prop_link_data</code> is available on multiple-value field elements.</p> <p>This solution relies on <a href="https://drupal.org/i/3550848">#3550848</a> to prevent duplicate linkers from appearing on individual rows. That issue added a <code>titleDisplay !== 'invisible'</code> check in <code>DrupalFormElementLabel.tsx</code>. Since Drupal core sets <code>#title_display =&amp;gt; 'invisible'</code> for individual items in multi-value fields (see <code>WidgetBase.php</code> lines 207-213), the linker only renders once in the table header.</p> <h3 id="ui-changes">User interface changes</h3> <p>The linker will now appear for multiple-cardinality field widgets, allowing users to link multi-value fields to component properties.</p> <p>Demo of using with Tags field in standard profile<br> <img src="https://www.drupal.org/files/issues/2026-03-09/tags-linking.gif" alt="Linking to tags field"></p> > Related issue: [Issue #3552918](https://www.drupal.org/node/3552918)
issue