Download & Extend

CCK fields not working

Project:Node factory
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

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

Comments

#1

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).

nobody click here