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
Comment #1
Bevan commentedThe patch still applies cleanly to 7.6
Comment #2
Juan C commentedThanks Bevan.
Comment #3
bartk commentedComment #4
that0n3guy commentedI 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.
Comment #5
bbdata commentedI 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.
Comment #6
Taxoman commentedComment #7
dr.user commentedPatch #1257342-5: A required field is not validated as a required field works for me.
Comment #8
nicktech commentedThe #5 patch fixed the problem. Thanks a bunch bbdata!
Comment #9
dave reidCommitted #5 to 7.x-1.x with some cleanups.
http://drupalcode.org/project/term_reference_tree.git/commit/cbf30ba