I've been pouring over the CCK modules to learn how to write my own widget, and I noticed the following code in nodereference_elements():

    ...
    'nodereference_select' => array(
      '#input' => TRUE,
      '#columns' => array('uid'), '#delta' => 0,
      '#process' => array('nodereference_select_process'),
    ),
    'nodereference_buttons' => array(
      '#input' => TRUE,
      '#columns' => array('uid'), '#delta' => 0,
      '#process' => array('nodereference_buttons_process'),
    ),
    ...

Shouldn't "uid" be "nid"? According to nodereference_field_settings(), the only database field defined for the field is "nid". I can only assume that Node Reference originally shared code with User Reference.

Also, I wasn't able to find much documentation on what "#columns" actually does. If the use of "uid" instead of "nid" didn't break things, does this attribute of form elements actually do anything?

Comments

anrikun’s picture

Title: Node Reference uses non-existant 'uid' column » Node Reference uses non-existant 'uid' and 'name' columns
Version: 6.x-2.6 » 6.x-2.x-dev
Priority: Minor » Major

+1
This issue has been posted *2 years ago* and this strange bit of code is still present in the latest 6.x-2.x-dev.
Does it mean that #columns is useless or what?
Please explain this and document #columns:

<?php
function nodereference_elements() {
  return array(
    'nodereference_select' => array(
      '#input' => TRUE,
      '#columns' => array('uid'), '#delta' => 0, // uid?
      '#process' => array('nodereference_select_process'),
    ),
    'nodereference_buttons' => array(
      '#input' => TRUE,
      '#columns' => array('uid'), '#delta' => 0, // uid?
      '#process' => array('nodereference_buttons_process'),
    ),
    'nodereference_autocomplete' => array(
      '#input' => TRUE,
      '#columns' => array('name'), '#delta' => 0, // name?
      '#process' => array('nodereference_autocomplete_process'),
      '#autocomplete_path' => FALSE,
      ),
    );
}
?>