I have a taxonomy term list with two levels. In the configuration of my content type I set the default value of "none". If I want to create a new node of this content type, I see in the selection list a term from my taxonomy instead of "none" and no terms of the second level are shown. I can see these terms only if I choose another term with subterms and then go back.
How could this be fixed?


stBorchert’s picture

Status: Active » Postponed (maintainer needs more info)

Could you post a screenshot of your field configuration? I've tested it in a clean install and the default value "none" is displayed first.
Did you set the field to be required?

cpritz’s picture

38.33 KB

Here is the screenshot of my field configuration. I set the field to be required.
Before I hav installed hierarchical select. Could it be, that there is a conflict?

stBorchert’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Postponed (maintainer needs more info) » Needs work

Ah, I see what you mean. The first option is selected by default but its children are not displayed unless one selects a different option first.
Ok, will try to fix this.

stBorchert’s picture

Status: Needs work » Needs review

I've committed a small fix for this to 7.x-1.x-dev (c420a48).
You may test this using the latest code from git or wait for the next dev-release.

thanks for the report.

cpritz’s picture

Hello Stefan,

the fix doesn't work for me. I try another one:

              // Use current term id as parent id for the next level.
              parent_id = parent.tid;
            if ((level > 1 || parent_id) || (settings_shs[fieldName].settings.create_new_terms || settings_shs[fieldName].settings.create_new_levels)) {
              // Try to add one additional level.

This works for me. With one (other problem). In the field configuration I set the default value to "none" for the categories. This works for subterms. But the parentterms show the first entry.

Do you have an idea where I can fix this?

parrot’s picture

I used stBorchert patch from git

diff --git a/js/shs.js b/js/shs.js
index 82b37ba..96175ea 100644 (file)
--- a/js/shs.js
+++ b/js/shs.js
@@ -48,7 +48,16 @@
               // Use current term id as parent id for the next level.
               parent_id = parent.tid;
+            var addNextLevel = false;
             if ((level > 1 || parent_id) && (fieldSettings.settings.create_new_terms && fieldSettings.settings.create_new_levels)) {
+              // Add next level in hierarchy if new levels may be created.
+              addNextLevel = true;
+            }
+            if (fieldSettings.settings.required && parent_id) {
+              // Add next level if field is required.
+              addNextLevel = true;
+            }
+            if (addNextLevel) {
               // Try to add one additional level.
               $select = shsElementCreate($field.attr('id'), fieldSettings, level);

all works good
sub-terms appeared

cpritz’s picture

I made a screenshot from the edit view of my content. The select list from the form "Region" show no list for the subterms. If I add the patch to shs.js the second list is not shown. If I fix this with #5 both lists and the list with the subterms are shown. But: the fix works only for the content edit form. In the view I got the list two-times :-(

If I make an exposed filter in views and choose shs and set required to TRUE then the first value is "none". How can I delete this first value? Because the user shoul choose one of the given options.

stBorchert’s picture

I've committed another small change so the following level is always displayed if a default value is set or the field ist required.
I've tested with various settings and different combinations of fields and it worked for me.

Please test (remember to clear the cache after changing the code) with next dev release or current code from git.

cpritz’s picture

Now it works for content creation and editing.

The only thing, that isn't working (for me) is, that the first value in an exposed, rquired filter in views is none. Because the user must choose a value I would expext, that one value is selected per default.

stBorchert’s picture

Status: Needs review » Fixed

Ok, seems the main issue is fixed now :)

Regarding the views filter: there eas a small error in the filter code so setting the required option has no visible effect. This is fixed now with commit 869275c.

Status: Fixed » Closed (fixed)

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