<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3AD_Linking_Assets_to_Person</id>
	<title>ICT:D Linking Assets to Person - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3AD_Linking_Assets_to_Person"/>
	<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:D_Linking_Assets_to_Person&amp;action=history"/>
	<updated>2026-04-17T16:26:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://mwiki.costasano.club/index.php?title=ICT:D_Linking_Assets_to_Person&amp;diff=1587&amp;oldid=prev</id>
		<title>Mngr at 19:29, 27 March 2026</title>
		<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:D_Linking_Assets_to_Person&amp;diff=1587&amp;oldid=prev"/>
		<updated>2026-03-27T19:29:31Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://mwiki.costasano.club/index.php?title=ICT:D_Linking_Assets_to_Person&amp;amp;diff=1587&amp;amp;oldid=1586&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Mngr</name></author>
	</entry>
	<entry>
		<id>https://mwiki.costasano.club/index.php?title=ICT:D_Linking_Assets_to_Person&amp;diff=1586&amp;oldid=prev</id>
		<title>Mngr: Created page with &quot;= Drupal: Linking Assets to Persons (MM Relationship Without Custom Code) =  == Purpose == This page documents the step‑by‑step implementation of a **many‑to‑many–style relationship between Person and Asset entities** in Drupal 11.x.  The objective is to allow editors to: * link existing Assets to a Person, * manage these links in a table‑based UI, * search and select Assets via a modal browser, * avoid custom modules and custom database tables.  This solutio...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:D_Linking_Assets_to_Person&amp;diff=1586&amp;oldid=prev"/>
		<updated>2026-03-27T19:22:33Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Drupal: Linking Assets to Persons (MM Relationship Without Custom Code) =  == Purpose == This page documents the step‑by‑step implementation of a **many‑to‑many–style relationship between Person and Asset entities** in Drupal 11.x.  The objective is to allow editors to: * link existing Assets to a Person, * manage these links in a table‑based UI, * search and select Assets via a modal browser, * avoid custom modules and custom database tables.  This solutio...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Drupal: Linking Assets to Persons (MM Relationship Without Custom Code) =&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
This page documents the step‑by‑step implementation of a **many‑to‑many–style&lt;br /&gt;
relationship between Person and Asset entities** in Drupal 11.x.&lt;br /&gt;
&lt;br /&gt;
The objective is to allow editors to:&lt;br /&gt;
* link existing Assets to a Person,&lt;br /&gt;
* manage these links in a table‑based UI,&lt;br /&gt;
* search and select Assets via a modal browser,&lt;br /&gt;
* avoid custom modules and custom database tables.&lt;br /&gt;
&lt;br /&gt;
This solution uses **standard Drupal mechanisms** and is upgrade‑safe.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
* Prefer configuration over code&lt;br /&gt;
* Avoid custom schema and join tables&lt;br /&gt;
* Use Drupal’s entity reference system&lt;br /&gt;
* Use contrib modules for UX, not data modeling&lt;br /&gt;
* Ensure maintainability and handover safety&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Conceptual Model ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Entity !! Role&lt;br /&gt;
|-&lt;br /&gt;
| Person || Main entity (e.g. historical person)&lt;br /&gt;
|-&lt;br /&gt;
| Asset || Reusable referenced entity (documents, images, objects, etc.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Relationship:&lt;br /&gt;
* One Person → many Assets&lt;br /&gt;
* One Asset → many Persons (implicit)&lt;br /&gt;
&lt;br /&gt;
Drupal handles this naturally via **entity references**.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Required Modules ==&lt;br /&gt;
Ensure the following modules are enabled:&lt;br /&gt;
&lt;br /&gt;
* Core:&lt;br /&gt;
** Field&lt;br /&gt;
** Views&lt;br /&gt;
* Contrib:&lt;br /&gt;
** Inline Entity Form (IEF)&lt;br /&gt;
** Entity Browser&lt;br /&gt;
&lt;br /&gt;
No custom module is required.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Step 1: Create the Entity Reference Field ==&lt;br /&gt;
&lt;br /&gt;
On the **Person** entity:&lt;br /&gt;
&lt;br /&gt;
1. Go to:&lt;br /&gt;
   &amp;lt;pre&amp;gt;&lt;br /&gt;
   Structure → Content types → Person → Manage fields&lt;br /&gt;
   &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Add a new field:&lt;br /&gt;
   * Field type: &amp;#039;&amp;#039;&amp;#039;Entity reference&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
   * Label: &amp;lt;code&amp;gt;Assets&amp;lt;/code&amp;gt;&lt;br /&gt;
   * Machine name: &amp;lt;code&amp;gt;field_assets&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Reference settings:&lt;br /&gt;
   * Target type: &amp;lt;code&amp;gt;Asset&amp;lt;/code&amp;gt;&lt;br /&gt;
   * Allowed bundles: select relevant Asset bundles&lt;br /&gt;
   * Cardinality: &amp;#039;&amp;#039;&amp;#039;Unlimited&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Save the field.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Step 2: Configure the Form Widget (Critical Step) ==&lt;br /&gt;
&lt;br /&gt;
1. Go to:&lt;br /&gt;
   &amp;lt;pre&amp;gt;&lt;br /&gt;
   Manage form display&lt;br /&gt;
   &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. For &amp;lt;code&amp;gt;field_assets&amp;lt;/code&amp;gt;, select widget:&lt;br /&gt;
   * &amp;#039;&amp;#039;&amp;#039;Inline Entity Form – Complex&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the widget settings (gear icon):&lt;br /&gt;
&lt;br /&gt;
   * ✅ Allow users to add existing entities&lt;br /&gt;
   * ❌ Allow users to add new entities&lt;br /&gt;
   * Entity Browser: select the Asset browser (configured in Step 3)&lt;br /&gt;
&lt;br /&gt;
4. Save the form display.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Important:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Do NOT select “Entity Browser” as the field widget itself.&lt;br /&gt;
That widget does not provide a table‑based UI.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Step 3: Create the Entity Browser for Assets ==&lt;br /&gt;
&lt;br /&gt;
1. Go to:&lt;br /&gt;
   &amp;lt;pre&amp;gt;&lt;br /&gt;
   Configuration → Content authoring → Entity Browser&lt;br /&gt;
   &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Create a new browser:&lt;br /&gt;
   * Name: &amp;lt;code&amp;gt;asset_browser&amp;lt;/code&amp;gt;&lt;br /&gt;
   * Display: Modal&lt;br /&gt;
   * Selection mode: Multi‑select&lt;br /&gt;
&lt;br /&gt;
3. Add a widget:&lt;br /&gt;
   * Widget type: View&lt;br /&gt;
&lt;br /&gt;
4. Create or select a View:&lt;br /&gt;
   * Base table: Asset&lt;br /&gt;
   * Display type: Entity Browser&lt;br /&gt;
   * Pagination: 10–25 items per page&lt;br /&gt;
   * Exposed filters:&lt;br /&gt;
     - Title&lt;br /&gt;
     - Type / taxonomy (as needed)&lt;br /&gt;
   * Fields:&lt;br /&gt;
     - Thumbnail (image style)&lt;br /&gt;
     - Title&lt;br /&gt;
     - Optional metadata&lt;br /&gt;
&lt;br /&gt;
5. Save the Entity Browser.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Step 4: Resulting Editor UX ==&lt;br /&gt;
&lt;br /&gt;
On the Person edit form:&lt;br /&gt;
&lt;br /&gt;
* Assets are displayed in a table&lt;br /&gt;
* Editors can:&lt;br /&gt;
  - Add existing Assets&lt;br /&gt;
  - Remove Assets&lt;br /&gt;
  - Reorder Assets&lt;br /&gt;
* Clicking “Add existing Asset” opens a modal browser&lt;br /&gt;
* Assets are searched and selected visually&lt;br /&gt;
&lt;br /&gt;
This provides a historian‑friendly workflow.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Step 5: UX Cleanup – Hide the Misleading “Add node” Button ==&lt;br /&gt;
&lt;br /&gt;
Inline Entity Form displays an intermediate chooser containing an&lt;br /&gt;
“Add node” button, which is misleading when creation is disabled.&lt;br /&gt;
&lt;br /&gt;
This is hidden via Gin admin CSS.&lt;br /&gt;
&lt;br /&gt;
=== CSS Location ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sites/default/files/gin-custom.css&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== CSS Rule ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
/* Hide misleading &amp;quot;Add node&amp;quot; button in Inline Entity Form chooser */&lt;br /&gt;
input.ief-entity-submit[data-drupal-selector*=&amp;quot;ief-reference-save&amp;quot;][value=&amp;quot;Add node&amp;quot;] {&lt;br /&gt;
  display: none !important;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This solution:&lt;br /&gt;
* requires no JavaScript&lt;br /&gt;
* survives AJAX rendering&lt;br /&gt;
* is upgrade‑safe&lt;br /&gt;
* does not depend on dialog wrappers&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Why No Join Table Was Used ==&lt;br /&gt;
An experimental approach using a “real” join table was evaluated and rejected because:&lt;br /&gt;
&lt;br /&gt;
* it required a custom module&lt;br /&gt;
* it required schema lifecycle management&lt;br /&gt;
* UI construction required many hooks&lt;br /&gt;
* upgrades would require maintenance work&lt;br /&gt;
&lt;br /&gt;
Drupal’s entity reference system already models the relationship correctly.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Performance Notes ==&lt;br /&gt;
* 1000+ Assets are handled without issue&lt;br /&gt;
* Only referenced Assets are rendered on the Person form&lt;br /&gt;
* Entity Browser uses pagination and indexed Views&lt;br /&gt;
* Thumbnails should always use image styles&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
This implementation achieves:&lt;br /&gt;
&lt;br /&gt;
* ✅ Many‑to‑many relationship semantics&lt;br /&gt;
* ✅ Clean table‑based UI&lt;br /&gt;
* ✅ Visual asset selection&lt;br /&gt;
* ✅ No custom code&lt;br /&gt;
* ✅ No custom schema&lt;br /&gt;
* ✅ Upgrade‑safe architecture&lt;br /&gt;
&lt;br /&gt;
This is the recommended approach for modern Drupal (11.x).&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Key Lesson ==&lt;br /&gt;
If a solution requires:&lt;br /&gt;
* custom join tables&lt;br /&gt;
* extensive hook usage&lt;br /&gt;
* complex UI overrides&lt;br /&gt;
&lt;br /&gt;
…it is often a sign that Drupal already offers a better abstraction.&lt;/div&gt;</summary>
		<author><name>Mngr</name></author>
	</entry>
</feed>