how to default value to select list CCK with form_alter I am usingCCK 2 (2.9), and I know that CCK field give the option to assign the default value using the pipe, for example 

Please select|Please select


But I am just curious about if exist a programatically way to assign a default value to a select list. I have several tries, using this kind of syntax:

$form['field_color']['value']['#default_value'] = 'Black'; //or
$form['field_color']['#default_value'] = 'Black'; //or
$form['field_color']['#default_value'][0]['value'] = 'Black';


but nothing. To me not is clear what is the correct syntax.

thanks in advance.
CCK requires a little voodoo to alter values with a hook_form_alter(). You need to implement a special type: after_build, so put this code in a custom.module:

//Declare the callback for after_build for page node form
function custom_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'page_node_form) {
    $form['#after_build'][] = 'custom_after_build';
  }
}

function custom_after_build($form, &amp;$form_state) {
  //For a select list you have to modify this to set default to black
  $form['field_select']['value']['#value'][0] = 'black';
  //if your field is multivalued you can put more
  $form['field_select']['value']['#value'][2] = 'red';

  //for a single text it's a little different:
  $form['field_text'][0]['value']['#value'] = 'black';
  //have a look at the form after after_build
  dsm($form);
  return $form;
}


Here are some (a little confusing/complicated but useful) articles regarding this:  


hook_form_alter() and CCK fields
FAPI/CCK Confusion: 'value' vs '#value'