CCK fields not working

andreiashu - March 6, 2009 - 07:15
Project:Node factory
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

In D6 version of node_factory you cannot set CCK fields.
I'm using CCK 6.x-2.x
Here is how i did managed to make it work:

  $edit = node_factory_create_node('my_node_type');
  node_factory_set_value($edit, 'title', 'Autocreated on ' . date('y-m-d G:i:s'));
  //these two are not working afaik
  //node_factory_set_value($edit, 'field_custom_field', 'telefon');
  //node_factory_set_cck_value($edit, 'field_custom_field', 'telefon');

  //this one works
  //field_custom_field is of type 'text'
  $edit['field_custom_field'] = array(
    0 => array(
     'value' => 'telefon',
    ),
  );
  node_factory_save_node($edit);

All the credit goes to http://current.workingdirectory.net/posts/2009/attach-file-to-node-drupal-6/
You can find there how he successfully attaches files to nodes programatically.

Cheers,
andreiashu

#1

andreiashu - March 6, 2009 - 07:16

I forgot to say that 'field_custom_field' is of type 'text' but it is a select list widget (don't know if this matters).

 
 

Drupal is a registered trademark of Dries Buytaert.