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.

  1. /** 
  2. * Implementation of hook_nodeapi(). 
  3. */  
  4. function custom_nodeapi(&$node$op) {   
  5.  switch ($op) {     
  6.   case 'presave':  
  7.    if ($node->type == 'order') {  
  8.     $node->field_date_creation[0]['value'] = format_date(time());  
  9.     $node->field_date_creation[0]['_error_element'] = 'field_date_creation][0][value';  
  10.    }  
  11.    break;  
  12.  }  
  13. }  

No comments: