Posted by petercook on November 26, 2014 at 12:47am
I'm working on a drupal 6 site, with the dinosaurs (I wish), and am using node_save(&$node). I get how to pass in the node values like the title, uid and type. I'm now in search of how to pass in the field values of my node type.
The API says, in many places that,"Modules and scripts may programmatically submit nodes using the usual form API pattern." If anyone can point me to the 'usual form API pattern' description I'd be very happy.
In code I have this:
<?php
$message = new stdClass();
$message->title = $title;
$message->type = 'free_text';
$message->uid = $node->invoice_uid;
$message->not_sure_what_goes_here = $field_free_text_message_value;
node_save($message);
?>My content type is "free_text" and the field is called "field_free_text_message".
Thanks.
Comments
Got it.
This seems to do the trick:
$message->field_free_text_message[0]['value'] = $message_block_contents;
I'm still interested in the location of the form API pattern description if anyone knows where it may be.
Thanks.