Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
askibinski CreditAttribution: askibinski commentedI 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...
Comment #2
Problue SolutionsSubscribe
Comment #3
x610 CreditAttribution: x610 commentedUsing 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
Comment #4
devkinetic CreditAttribution: devkinetic commentedExample of this in a form_alter (D6):
Note the taxonomy is set to multiple, and this code is for the content type you do not want to allow multiple selections on.