Relation to a collection type doesn't use the good field of the linked collection

System Information
  • Strapi Version: 4.3.8
  • Operating System: Windows Desktop (11)
  • Database: MariaDB
  • Node Version: 16.15.0
  • NPM Version: 8.15.1
  • Yarn Version: using npm

Hi !

I have two collections that are connected by a HasOne relation (clinical trial has one clinical trial site). I have this structure in the Content type Builder :

Linked collection (clinical trial site) :


Main Collection (clinical trial) :

Linked collection’s configuration (clinical trial site) :

As you can see, the entry title is as well set on the “Alias” field. But when I want to add a clinical trial site in my clinical trial, he takes the “Name” field so I cannot search in the “Alias” field that would be very practical.
I tryed to add the “mainField” attribute on my clinical trial site component because I saw several topics that spoke about it (example), but Strapi doesn’t matter about it :

{
  "kind": "collectionType",
  "collectionName": "clinical_sites",
  "info": {
    "singularName": "clinical-site",
    "pluralName": "clinical-sites",
    "displayName": "Clinical trial site",
    "description": ""
  },
  "options": {
    "draftAndPublish": false,
    "mainField": "Alias.displayName"
  },
  "pluginOptions": {},
  "attributes": {
    "Alias": {
      "pluginOptions": {},
      "type": "string",
      "required": false,
      "private": true,
      "displayName": "Alias"
    },
    "Name": {
      "pluginOptions": {},
      "type": "string",
      "required": true
    },
    "Address": {
      "type": "component",
      "repeatable": false,
      "pluginOptions": {},
      "component": "location.address"
    }
  }
}

The purpose is to search in the “Alias” field to identify and add a clinical trial site to a clinical trial, not in the “Name” one.

If someone has juste a lead, it could be nice, thanks!

1 Like