2009-02-21

Drupal 6 & CCK field filling manually

If you should fill CCK field manually you must fill 'value' field and '_error_element' field. Otherwise data will not be accepted.


/**
* Implementation of hook_nodeapi().
*/
function custom_nodeapi(&$node, $op) {
switch ($op) {
case 'presave':
if ($node->type == 'order') {
$node->field_date_creation[0]['value'] = format_date(time());
$node->field_date_creation[0]['_error_element'] = 'field_date_creation][0][value';
}
break;
}
}

No comments: