This is what i would like to do.
On my taxonomy term page (www.mywebsite.com/taxonomy/term/2) there is a link to add a node (www.mywebsite.com/node/add/article)
The Article content type has an Entity Reference field.

How to prepopulate the Entity Reference field with term 2 after clicking on the link?

Comments

TD44 created an issue. See original summary.

yseki’s picture

Component: Documentation » Plugins
Assigned: Unassigned » yseki
Category: Support request » Feature request

Hi TD44,

On Drupal 7 there is a module that I heavily used called Entity reference prepopulate and what it does is exactly what you are asking for. Unfortunately, there is no version for Drupal 8.

I've never tried to achieve it using Business Rules and unfortunately, it's just almost possible.

  • We can verify the URL to knows if you are trying to prepopulate one form field.
  • We can recover this value from the URL
  • We can change the form field... but there is no action to prepopulate the field with some value. I've prepered the plugin only witch actions to make the field required, optional, ready only or hidden

It's not a hard feature to implement, I'm just with no time this week and the next one to work on it, but I can do it in the second week of September.

I'm moving it to feature request.

If you or someone else has the coding skills to work on it earlier than me, the file to implement this feature is business_rules/src/Plugin/BusinessRulesAction/ChangeFieldInfo.php

TD44’s picture

Thank you for your answer yuriseki. However i'm using Drupal as builder, i can't start working on this feature :/ I stay tuned.

TD44’s picture

What's up yuriseki. Did you find the time to add this plugin (Prepopulate module still does not work on my website)

yseki’s picture

Hi TD44,

Please, attach what you've done on this issue to allow me to see what's going on with your code.

rodmarasi’s picture

does https://www.drupal.org/project/prepopulate/issues/2668010 link can solve your problem? sorry. never use this module

sketman’s picture

@TD44: You can use Prepopulate module for what you need, I have just implemented it in my project. You need to use format in post #50 in link provided by @rodmarasi