How to add a text Autocomplete Widget programmatically Trying to include a text Autocomplete Widget in a compound field (more here) using the snipped below.. but the field does not autocomplete. What am I doing wrong?

  $element['contact_name'] = array(
    '#title' =&gt; t('Name'),
    '#type' =&gt; 'textfield',
    '#default_value' =&gt; $defaults['contact_name'],
    '#weight' =&gt; 2,
    '#size' =&gt; '100',
    '#max_length' =&gt; '255',
    '#widget_type' =&gt; 'autocomplete_widgets_flddata',
    '#autocomplete_match' =&gt; 'contains',
    '#autocomplete_case' =&gt; '0',
    '#widget_module' =&gt; 'autocomplete_widgets',
  );
Ok, so if you're trying to do it through hook_form_alter, you have to read the documentation on altering CCK fields. 

The short version: the CCK fields are processed after the form is built. If you want to change anything in them, you have to add a callback to $form['#after_build'] (but do not replace the array, just add to it). Then implement the function, change values in $form and return the $form.