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?

Comments

jlancaster’s picture

Same 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!

jlancaster’s picture

StatusFileSize
new731 bytes

Found 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]);
}

manumilou’s picture

Issue summary: View changes
StatusFileSize
new640 bytes

The 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.

Dave Cohen’s picture

Status: Active » Needs work

Thanks for pointing out the problem exists in 7.x, I was no aware.

Wouldn't the fix be more efficient to try something like

if (count($form[$field_name][$field_language]['#options']) <= 1 && isset($form[$field_name][$field_language]['#options'][0])) {
  // snip...
}

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.

manumilou’s picture

I am not sure either which is none's index (_none ?). It would work as well, and yes, could be easier to understand.

Dave Cohen’s picture

I 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?

manumilou’s picture

Yes, it is _none.

Ref (options.module, line 255):

$label = theme('options_none', array('instance' => $instance, 'option' => $properties['empty_option']));
$options = array('_none' => $label) + $options;

I attached the updated patch, should be working well.

  • Dave Cohen committed 1ac05cc on 7.x-1.x authored by manumilou
    fixes #1033394. Clean up logic around how many term options appear on...
Dave Cohen’s picture

Status: Needs work » Patch (to be ported)

I pushed the fix to 7.x. Still needs backport to 6.x.

I cleaned up the logic slightly:

      // Don't show if the only option left is <none>.
      if (empty($form[$field_name][$field_language]['#options']) ||
          (count($form[$field_name][$field_language]['#options']) == 1 && isset($form[$field_name][$field_language]['#options']['_none']))) {                                                                                                                        
        $form[$field_name]['#access'] = FALSE; 
      } 

  • Dave Cohen committed 1ac05cc on 8.x-1.x authored by manumilou
    fixes #1033394. Clean up logic around how many term options appear on...
vladimiraus’s picture

Status: Patch (to be ported) » Closed (outdated)

Thank you for contribution. 👍
Drupal 6 is no longer supported. 🤷‍♂️
Closing as outdated. 🔐