Prepopulate a field in a Reference Dialog Box I have 2 content types named Incident and Migrant. Both of them have fields that reference each other. My question is how to prepopulate a field in a reference dialog box while the node is being edited?



How am I going to prepopulate Incident field with Incident 36 nid. When the popup/dialog loads? Assuming that Incident field is a Autocomplete Text Field?

Here's what I tried, I have tried Entity Reference Prepopulate but, I figured that that the Reference Dialog is displayed via iframe so getting the nid from the URL wont work.

I'm very new to drupal and still in the learning curve so if possible answer me in a detailed fashion.

Modules i used

Entityreference prepopulate
Reference Dialog
Yes, you can.
What you need for this?
1) references_dialog
2) entityreference_prepopulate 
3) your custom_module.
For example field that you want to make with prepopulated field in url is entityreference.
Here is link to youtube how to use entityreference_prepopulate and URL https://www.youtube.com/watch?v=z9C4Uf6euLY.

After this you should override your "Create ..." link. How to do this?
Easy. Just implement hook_references_dialog_widgets_alter in your custom module and change name of function that generate add link

/**
 * Implements hook_references_dialog_widgets()
 */
function mymodule_references_dialog_widgets_alter(&amp;$widgets) {
  $widgets['entityreference_autocomplete']['operations']['add']['function']
    = 'mymodule_references_dialog_entityreference_add_link';
}


And than you can define your add link function: 

function mymodule_references_dialog_entityreference_add_link($element, $widget_settings, $field, $instance) {
// blah blah from original function
// Here you can catch field what you need and define url with $_GET parameters for it.
}


That's all. Enjoy reference dialog with get params in url.