I have a Drupal 7 node with custom fields. I have no problem setting values to the single text fields but I'm not sure how to set my select list field to one of the allowed keys of the field.
This is the code I've tried to assign the select list to the 'pending' key.
$node->field_referee_status['und']['tid'] = 'pending';
Node creation code:
// CREATE NODE $node = new stdClass; $node->type = 'referee'; $node->title = 'Referee report for xx'; $node->uid = $user->uid; $node->status = FALSE; $node->field_referee_status['und']['tid'] = 'pending'; $node->field_referee_id['und']['value'] = 'test'; $node->field_testff['und']['value'] = "testworked"; node_object_prepare($node); node_save($node);
Question: Does anyone know the correct way to assign the key value to a custom select list field when creating Drupal nodes programmatically?