default value for entity reference field I have a form with an entity reference field and I need to add a default value. I've tried

$form['field_op_product']['und'][0]['target_id']['#default_value'] = $product_node-&gt;nid;


but, that doesn't work. Any idea on how to do this?

The widget type is "AutoComplete"
From the sample code given in question, I assume the hook_form_alter() is used. You should first load the referring node, get the Node Title and Node ID from it, and then set the default value using both. This works. 

Setting the default value using Node ID alone will not work.

$entity_node = node_load($nid);
if ($entity_node) {
    $form['field_op_product'][LANGUAGE_NONE][0]['target_id']['#default_value'] =
        "$entity_node-&gt;title ($entity_node-&gt;nid)";
}