I have a cck field that I need to access in my hook_form_alter so I could set a certain field’s default value with a dynamic value.
Apparently, node_load does not do the job for me.
if ($form_id == 'some_form_id') {
$node = node_load($item->nid);
$somevariable = $node->field_cck_foo[0]['value'] * 2;
$form ['xxx']['xxx']['#default_value'] = $somevariable;
}
How am I able to access the node items so I could use it inside hook_form_alter? Please advice. Thanks.
node_load() WILL get you all the CCK fields values, try doing a var_dump to see what’s comming.
If node_load() isn’t bringing the full node structure, try clearing the cache with this workaround http://drupal.org/node/158237#comment-4593950