This error

Notice: Undefined offset: 2 in _hierarchical_select_hierarchy_generate() (line 1812 of /sites/all/modules/hierarchical_select/hierarchical_select.module).

always appear when I am saving my product display node. I'm using HS with commerce kickstart.

THanks & regards,

Max.

Comments

acrollet’s picture

I don't have time to fully investigate this issue now, but it appears to arise when the 'Maximum number of levels allowed' setting under the editability section of the widget settings doesn't match the number of levels present in the vocabulary. In my case, the vocabulary went three levels deep, but the max number of levels allowed setting was at 2. I'm not sure if the best approach for a fix is to

a) add a hook invocation on term creation to adjust the max levels allowed setting
b) modify the code to avoid the notice when things don't match up (and potentially check when generating the widget settings form)
c) some other approach.

kurtzhong’s picture

really good information on this issue. thx. :)

janicak’s picture

Hi there,

In addition to the Undefined offset error, I'm also encountering the following issue, so perhaps they are related...

Namely, if "allow creation of new terms" is selected, and jquery_update is enabled, the box for the next lower level disappears when the selection in the higher level changes and will not reappear.

I went through most of the variations of settings for the HS widget and jquery_update, disabled most other modules and fields. Same behavior with 7.x-3.0-alpha5.

Any help would be greatly appreciated!

mrpauldriver’s picture

We are encountering the error mentioned in first post.

Is there any more insight into what is happening here?

wim leers’s picture

Status: Active » Needs work

It'd be great if somebody could debug this and then provide a patch.

wim leers’s picture

summit’s picture

Status: Needs work » Active

Hi,
I do not see a patch here, thats why I set it to active and not "needs work".
Any news on this please? Is the shortterm-fix to set the 'Maximum number of levels allowed' setting under the editability section of the widget settings the same as the number of levels present in the vocabulary?

Greetings, Martijn

summit’s picture

Hi,
I did set the 'Maximum number of levels allowed' setting under the editability section of the widget settings the same as the number of levels present in the vocabulary.
Still problems with this and error as stated..

greetings,
Martijn

Bitvark’s picture

Issue summary: View changes

Hi,
I had similar problem with a standard drupal installation using taxonomy term reference field with hierarchical select widget.
Don't know if it's useful for you, anyway to get free from this notice I followed 3 steps:
1) I provided same number of levels for related vocabulary and hierarchical maximum number of levels allowed (as vocabulary had one level less, before).
2) Then, I returned in field widget setting and drupal showed me an additional level in table "Per-level settings for creating new terms".
3) Just saved widget settings and notice disappered.

Bitvark’s picture

Issue summary: View changes
summit’s picture

Hi,
This helped me a lot to get rid of this error with a Migration. The levels need to have an exact match!
but it appears to arise when the 'Maximum number of levels allowed' setting under the editability section of the widget settings doesn't match the number of levels present in the vocabulary. In my case, the vocabulary went three levels deep, but the max number of levels allowed setting was at 2. I'm not sure if the best approach for a fix is

greetings, Martijn

7thkey’s picture

hi there,
Is there any progress on this?
Is it a problem with the module or the library?

Cheers

7thkey’s picture

Added as duplicate of this issue.

giupenni’s picture

Same problem

firfin’s picture

Error also shows up if 'Enable level labels' is checked in widget settings and not every level has a label set.
To 'solve' this, simply set a label for all levels.

firfin’s picture

stefan.r’s picture

If anyone has a fix, I'll be happy to review.

istavros’s picture

In 7.x-3.0-beta8 if you change line 1895 from
$label = ($config['level_labels']['status']) ? t($config['level_labels']['labels'][$depth]) : '';
to
$label = ($config['level_labels']['status'] && isset($config['level_labels']['labels'][$depth])) ? t($config['level_labels']['labels'][$depth]) : '';

just like in line 1851, the error should go away.
And of course you could just have labels for all levels. I use Features to track the field settings so I just changed

'level_labels' => array(
      'status' => 1,
      'labels' => array(
        0 => '- Select -',
      ),
    ),

to this

'level_labels' => array(
      'status' => 1,
      'labels' => array(
        0 => '- Select -',
        1 => '',
        2 => '',
      ),
    ),

and it works fine.

gold’s picture

Status: Active » Postponed (maintainer needs more info)

It has been a year since this issue saw any comments. I am unable to replicate the issue. Looking at the code in #18 this is not currently in the codebase either.

If this is still an issue could someone please edit the description to give instructions to replicate the issue starting from "Install Drupal with the Standard profile". If you could also mention the version of PHP you're testing on that may also help.

I'm happy to generate a patch from the suggestions above, but I first need to see the error in action so I can see that the updates fix it.

Cheers.