Score:1

Node edit form - Is it possible to load entity reference field data on click after the form has finished loading?

us flag

I have a custom node type (let's call it Project) with many fields. Three of these fields are of an Entity reference type, referencing other related nodes (let's call them Project Attachments A, B, and C).

There are sometimes hundreds of A, B, and C Project Attachments. This puts considerable load on the Project node edit form due to many DB queries being run, sometimes causing timeouts. I have already changed the display of the Project Attachments fields to be read-only and display the associated node ID within the form, which has reduced page load. It displays like this:

Attachment A

  • Test - Copy (node ID)
  • Report Test (node ID)
  • Application_1 (node ID)
  • Other Reference (node ID)
  • Any doc - Copy - Copy (node ID)
  • Any Any (node ID)
  • Fee Breakdown (node ID)
  • .........
  • .........

Is it possible to further change the behaviour of these fields within the form so that there is a button or link that the user can click to only display the associated data when required (ie, not on form load)? Something like:

Attachment A
<button>Click to show data</button>

No Sssweat avatar
ua flag
Maybe you're better off doing the opposite? Make all attachment nodes reference your project node.
TheDrot avatar
us flag
It should be possible with a custom field widget on an entity reference field type https://www.drupal.org/docs/creating-custom-modules/creating-custom-field-types-widgets-and-formatters/create-a-custom-field-widget
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.