[drupal-devel] Question on taxonomy_form() function

Morbus Iff morbus at disobey.com
Wed Mar 30 14:32:22 UTC 2005


> My problem is that the second vocabulary (vid==2, tid=={3,7}) allows multiple
> selection, whereas the first vocabulary (vid==1, tid==1) does not. The way
> the underlying form_select() called by taxonomy_form() seems to work is that
> it uses a subarray for the field only if multiple selection is allowed. This
 >
> There isn't a good way to match up those sub-subarrays with the vid to which

In my fiddling with folksonomy, I know what you're talking about. The 
taxonomy form doesn't, in any instance, give a damn about the vid. The 
ONLY effect of choosing "Multiple select" is the UI element: there is no 
underlying code that actually checks to make sure only $n terms were 
passed for a particular $vid. As a bug, "Multiple select is determined by 
form UI, not logic."

With that said, the $vid isn't required for taxonomy_save to work. To the 
underlying code, all it cares about is the $nid and the $tid, which get 
saved into term_data. The $vid isn't required for this - the $tids are 
unique so you can always find the $vid later on in life. The subarray 
you're seeing is just a side-effect of the "Multiple select" option; the 
"no good way to match up with the $vid" is entirely "by design".

If you're really insanely interested in the $vid, you could use the 
_nodeapi on 'validate' to enforce your own checks: look over each $tid, 
find the matching $vid, and check against vocabulary.multiple, and 
form_set_error if you received more than you expected.

> they point, so simple conditional logic inside my foreach{} loop is not going
> to be feasible if the site administrator has associated more than one multi-term-

I'm not sure why you actually /need/ the $vid.

-- 
Morbus Iff ( you are nothing without your robot car, NOTHING! )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus



More information about the drupal-devel mailing list