A required single-value term reference field that uses this widget to select leaves only, validates even when no term is selected. But a required field should require that a term is selected.

This patch fixes the bug by using empty() instead of comparing to 0 in three places in _term_reference_tree_widget_validate().

It also adds a space before the parenthesis in if clauses in the same function, which is Drupal standard.

I only just noticed that updates for this module are recently available. I have not checked if the bug exists in newer versions of the module. I have not tested the module with other configuration of the widget.

Comments

Bevan’s picture

Version: 7.x-1.2 » 7.x-1.6

The patch still applies cleanly to 7.6

Juan C’s picture

Status: Needs review » Reviewed & tested by the community

Thanks Bevan.

bartk’s picture

Status: Reviewed & tested by the community » Closed (fixed)
that0n3guy’s picture

Version: 7.x-1.6 » 7.x-1.9
Status: Closed (fixed) » Needs review

I think this bug crept back up. Using 1.9 on a node that is required, Start minimized, default value of n/a, number of values: 1.

If I choose nothing, the node submits just fine... no error to fill out the field.

bbdata’s picture

I corrected 1.9 based on the previous patch. I am curious as to why $child['#value'] !== 0 is favored.

Under my current use cases, validation is ignored even when a term tree is required.

Taxoman’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
Priority: Normal » Major
dr.user’s picture

nicktech’s picture

The #5 patch fixed the problem. Thanks a bunch bbdata!

dave reid’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.