When I grant permissions to individual users using tac_lite by selecting more than one term in a given scheme's list (that is, the list that shows up in the user's Access by Taxonomy tab), the taxonomy select list showing the allowed terms shows up in the node add/edit form as expected. However, when I select a single term in the scheme's list, the taxonomy select list is not showing up in the node add/edit form. The taxonomy is configured to be required for the node type.
The scheme has "Visability" and "Visibility on create and edit forms" checkboxes checked.
This would not be a problem except that the single term defined in the scheme is not being assigned to the node when created. Anyone know why this is happening? If the vocabulary is required on the node type, why is the user able to create the node without populating the taxonomy select list?
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | taxonomy-with-single-term-not-showing-1033394-7.patch | 613 bytes | manumilou |
| #3 | taxonomy-with-single-term-not-showing-1033394-3.patch | 640 bytes | manumilou |
| #2 | tac_lite_create.patch | 731 bytes | jlancaster |
Comments
Comment #1
jlancaster commentedSame problem here... I forgot about this quirk until I did an upgrade of tac_lite today and started running into the problem again. I'm pretty sure there was a patch to an older version to fix this. If I can find the fix I'll try to post it here for you!
Comment #2
jlancaster commentedFound it. Line 51 of tac_lite_create.module in 6.x-1.5. The intended functionality is to hide the term "none" if it is the only term, but some of us obviously use this module to only show/assign one term to a customer. More robust checking of the actual value of the term should be implemented. For me though, I don't care if a term shows so I've attached a patch that just comments out the bad lines.
If you don't want to apply the patch, just go and comment out the following (tac_lite_create.module line 51):
if (count($form['taxonomy'][$vid]['#options']) <= 1) {
// Don't show if the only option left is .
unset($form['taxonomy'][$vid]);
}
Comment #3
manumilou commentedThe problem is still there in the 7.x-1.x version. Here is a patch that fixes it by checking if the only remaining item in the select is a taxonomy term on which the user has access to.
Comment #4
Dave Cohen commentedThanks for pointing out the problem exists in 7.x, I was no aware.
Wouldn't the fix be more efficient to try something like
I'm not actually sure if none's index is 0 or -1. I don't think the array_intersect() code is easy to understand.
Comment #5
manumilou commentedI am not sure either which is none's index (_none ?). It would work as well, and yes, could be easier to understand.
Comment #6
Dave Cohen commentedI think it may be _none, from options.module. Jeez it's hard to find anything in Drupal anymore. Too bad it's not a constant.
I don't have a test case for this handy. Can you try testing for '_none' and update the patch?
Comment #7
manumilou commentedYes, it is _none.
Ref (options.module, line 255):
I attached the updated patch, should be working well.
Comment #9
Dave Cohen commentedI pushed the fix to 7.x. Still needs backport to 6.x.
I cleaned up the logic slightly:
Comment #11
vladimirausThank you for contribution. 👍
Drupal 6 is no longer supported. 🤷♂️
Closing as outdated. 🔐