Skip to content

Instantly share code, notes, and snippets.

@segovia94
Last active August 29, 2015 14:04
Show Gist options
  • Save segovia94/858eb55863fc1594901e to your computer and use it in GitHub Desktop.
Save segovia94/858eb55863fc1594901e to your computer and use it in GitHub Desktop.
<?php
// node/add/project-review/%nid
$nid = arg(3); //Gets the nid from the url
if ($nid) {
//get the project node
$node = node_load($nid);
//add the entity reference to the project of it does not already have one
if (empty($form['field_project_refence'][LANGUAGE_NONE][0]['target_id']['#default_value'])) {
$form['field_project_refence'][LANGUAGE_NONE][0]['target_id']['#default_value'] = $node->title . ' (' . $node->nid . ')';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment