The subject line pretty much says it - I have two content types which use most of the same content taxonomy fields, but in one of them I only want people to be able to choose one value from most of the vocabularies, whereas on the other they need to be able to choose more than one if they want to.

But the "Number of values" setting is located under Global settings, not content-type-specific settings, so it looks like I can only set it one way. Is there some way around this? Or will I have to create all the fields twice, once as multiple select and once as not?

Comments

askibinski’s picture

I believe the only way would be to change te select form element using the hook_form_alter.

Check out link beneath for more info:
http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...

Problue Solutions’s picture

Subscribe

x610’s picture

Using UI you can't use one field as multiple and single in different content types.

The best solution is to create another field.

Another solution using hooks:
1. Set Number of Values to Unlimited
2. In hook_form_alter for needed content type set multiple attribute for select to false

devkinetic’s picture

Issue summary: View changes

Example of this in a form_alter (D6):

function MODULE_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'TYPE_node_form':
      foreach($form['taxonomy'] as $vid => $settings) {
        if ($settings['#title'] == "NAME OF VOCABULARY") {
          $form['taxonomy'][$vid]['#multiple'] = 0;
          unset($form['taxonomy'][$vid]['#size']);
        }
      }
      break;
  }
}

Note the taxonomy is set to multiple, and this code is for the content type you do not want to allow multiple selections on.