How to make a CCK field appear as single-value on one Node Type, and multi-value on another Node Type? I have a CCK field (text, options widget, predefined value list) I'm using on two Node Types.  On one Node Type, I'd like to allow an unlimited number of selections.  On the other Node Type, I'd like to restrict the user to a single selection.

Currently, I've configured the CCK field to allow unlimited values, and am using this hook_form_alter() code:

/*
 * Implementation of hook_form_FORM_ID_alter().
 */
function custom_form_custom_node_form_alter(&amp;$form, &amp;$form_state) {
  // http://drupal.org/node/726282
  $form['#after_build'][] = 'custom_after_build';
}
function custom_after_build($form, &amp;$form_state) {
  $form['field_custom' ]['value']['#multiple'] = false;
  return $form;
}


So far, so good: the field shows up as single-value on one Node Type, and multi-value on the other.

But when I click Save, the data doesn't end up in the node — I presume this is because the single-value and multi-value fields store data differently, and CCK's submit handler is expecting the data in a different format.

What do I need to do to get the single-value field data into a format CCK will understand for a multi-value field?

So far I've tried:


implementing a #validate handler to alter the $form_state array to match the $form_state array produced by submitting a multi-value field — no effect
implementing hook_nodeapi() $op==='validate' to alter the field values in the $node object — no effect
You need to implement the hook_nodeapi and use the operation "presave"

Presave will have all the data submitted from the form and you can then alter it here just before it goes into the database.

If you have the devel module do a dpm($node); to see what data you are getting.

the important thing is that the field for multi values will be expecting an array so it may be as simple as grabbing the data from the form and adjusting it to pass it as an array.

EDIT

Aah ok validation....

I would probably turn off validation for that item by using the: '#element_validate' property, this way you can target validation for that specific element see the fapi docs on drupal. 
http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/6#element_validate