I am able to programmatically create and populate nodes by using techniques such as this :
$nodeAr['field_name'][0] = array('value' => $aValue);
// ... etc ... //
$node = (Object)$nodeAr;
// ... //
node_save($node);
But I can't seem to get this to work for radio buttons. How would I set up the array for the field so that it converts to an object value that Drupal and CCK recognize when saving the node?
Comments
Comment #1
jmlavarenne commentedComment #2
Antinoo commentedSubscribing.
I think it would be very very useful for other modules a cck_* function which could handle this kind of task.
Not only for radio buttons, but for every CCK type.
You can see an imaginary example in this forum topic I opened yesterday.
Maybe something like that already exists, or there's some code which could be reused. I'm sorry, but I don't know.
Let me know what do you think about.
Greetings, Giovanni
Comment #3
jmlavarenne commentedThe above technique also fails with select fields.
The only solution I've come up with which works is to save the value into the table field after the node has been created (by first retrieving the node->id) with an SQL command.
Comment #4
gcassie commentedTry manually creating a node of the type that has radio buttons, and put in some values. Then use the devel module to view how the data is structured with a dev load. If you mirror that structure, it should work.
Hope I understood your question properly.
Comment #5
karens commentedClosing old issues. None of us is using the D5 version any more, so hard to provide any support. Sorry.