I need to manage a few different types of objects, let's say "car", "pickup", and "van". These are similar enough (for my purposes) that I can define a single content type and associated code for "vehicle" and use it for all of them, along with a field that specifies the exact type of the object. This allows me to do things like have one page that shows all the cars, one page that shows all the pickups, and so on. I have this code running; everything is fine.
I now want to add an OPTIONAL tag field to these items, using the taxonomy / term_reference stuff in Drupal. The catch is that I want to have a separate tag taxonomy for each of my different kinds of vehicles, so that "car" tags don't show up in the truck's autocomplete suggestions. (Trust me -- in the context of my app, this makes sense.) The question is how to do it; the complicating factor is that the vocabulary for a tag field has to be defined when the field is added to the content type, and, remember, my content type is generic across all the types of vehicles.
Ugly possibility #1: Define a single tag field -- field_vehicle_tags? -- in the content type and write some magical code in a form_alter or theme or after_build hook or somesuch that, when building the edit form for the node, checks to see what kind of vehicle is being created (this is known upon entry to the form) and bashes the appropriate vocabulary into the field's autocomplete process. I don't know that this is actually possible, and I suspect the opportunities for screwing myself are endless.
Ugly possibility #2: Define one tag field for each kind of vehicle -- field_car_tags, field_pickup_tags, etc -- each of which is connected to its own taxonomy. Then, use the theming hook to throw away (= not render as part of the form) all the tag fields except for the one that matches the kind of thing being edited. This is stupid and wasteful in all sorts of ways, but I'm pretty sure it would work.
Any thoughts or alternatives? I'm currently leaning towards #2, but if there's a better alternative, I'd love to hear about it.