How to prepoulate entity reference field to a content

Created on 6 February 2024, 11 months ago
Updated 14 April 2024, 8 months ago

Problem/Motivation

I am building a site where users from different institutes will be able to enter content related to their institute. I have created a content type called Institute and put a term reference field to institute in the user account page. Each user can belong to a single institute only.

I have a content type called Contouring System in which there is an entity reference field to the institute. I would now like to prepopulate the value in the select list with the user's institute.

Steps to reproduce

I have created an entity reference field called "field_institute" in the user account page.
Another field called "field_institute_name" in the content page.
I have tried to pre-populate the data in the field_institute_name field using the following token:

[current-user:field_institute:entity:nid]
Seeing the image on the module page I have also tried this code
target_id: '[current-user:field_institute:entity:nid]'

Both do not work.
If however I just put node ID of one of the institute content fields then the select list does show the value (see attached image).

Thank you for any help with this.

💬 Support request
Status

Active

Version

1.6

Component

Documentation

Created by

🇮🇳India santam

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024