Change select options within a nodereference

First you'll have to make use of hook_form_alter() function.

function example_form_alter(&$form, $form_state, $form_id) {
  $form['field_example_reference']['#pre_render'] = array('example_change_node_reference');
}

Now the node reference will look for a example_change_node_reference() function which will return an array of options.

function example_change_node_reference($element) {
      $element['nid']['nid']['#options'] = array($node->;nid => $node->title);
  return $element;
 
}

Make sure you pass the $element variable into the function. More info: http://drupal.org/node/339730.

Category: 
Tags: 

Ivan is the founder of Web Wash and spends most of his time consulting and writing about Drupal. He's been working with Drupal for 6 years and has successfully completed several large Drupal projects in Australia.

Connect: Twitter drupal.org LinkedIn App.net