Community & Support

Setting allowed values for CCK checkbox field programmatically

Hi,

I want to set the allowed values for a CCK checkbox field with PHP. I have created a content type 'shortprofile' with a CCK field 'field_sp_tags'. This is a text field with the checkbox widget (and allowed values empty).

Now with hook_form_alter I want to set the allowed values of this field. I tried the following:

function mymodule_form_alter(&$form, $form_state, $form_id) {

  if ($form_id == 'shortprofile_node_form') {
    $form['#field_info']['field_sp_tags']['allowed_values'] = "Test";
  }
}

I expected that this should result in a single checkbox labeled 'Test'. But unfortunately this is not the case. I just get the label of the field field_sp_tags and no checkboxes at all. What is wrong here? Any ideas?

nobody click here