I want a flexinode field that points to another flexinode. Specifically, I want a field in flexinode-4 that points to any nid representing a flexinode-1. I'd like this as a drop-down.
I started by copying field_book.inc, changing most instances of 'book' to my custom field name, then adjusting the SQL statements to return nodes of type 'flexnode-1'. Mostly, it's working.
My form code looks like this:
function flexinode_field_product_form($field, &$node, $error) {
$fieldname = 'flexinode_'. $field->field_id;
$result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.status=1 AND n.type='flexinode-1' ORDER BY n.title"));
while ($node = db_fetch_object($result)) {
$options[$node->nid] = $node->title;
}
if (!is_array($node->$fieldname)) {
$node->$fieldname = unserialize($node->$fieldname);
}
if (count($options)) {
return form_select(t('Registered Items'), $fieldname, $node->$fieldname, $options, t('Select from the list') . ' ' . theme('error', $error[$fieldname]), 0, 0);
}
}
The field appears to be defined properly in the database (field_id 47, ctype 4, etc). The drop-down is appearing correctly on the form. The data for the field appears to be stored correctly in the database (nid 1143, field_id 47, textual_data s:3:"754";).
However, it doesn't come back out. Viewing the node produces the label for the field, but no data. Printing some debugging info, I've determined that the code is correctly identifiying the field as 'flexinode_47' however, $node->flexinode_47 is empty.