views:

379

answers:

1

I have module that implements custom content type via NodeAPI hooks (hook_insert, hook_update etc). I want to add CCK field to this content type and populate it via hook_nodeapi calls like create or update (to show content nodes in Views).

Problem is, I cannot access CCK fields for this content type. Sure, it's enabled on "Manage Fields" page, but when I load any node of this type with Devel module, I cannot see field attribute (field_flag) in node object. I can see it under "Dev Render" tab as part of "content" attribute, like $node->content['field_flag']['#value'], but if I assign value to $node->field_flag or $node->content['field_flag']['#value'] and call node_save, CCK fields are not saved.

Maybe I must call some other function to save CCK fields? Or what may be wrong with this setup?

+1  A: 

I believe the field is

$node->field_flag[0]['value']

It's that way in Drupal 6, it doesn't follow the actual name of the field or table field name. The easy way to see what the field is is to fill out a node, then dump it out to see its structure. That will give you the name it is expecting in node_save. I have not used Drupal 5 in a while, but you can't be too far off. You are close.

Kevin
Thanks, that's it :) It seems Devel won't show me this field if it was not set to anything.
Kuroki Kaze