During the callback to create a new item in any hierarchical select widget, the following error appears in the system log:

Notice: Undefined variable: config in _hs_process_render_create_new_item() (line 561 of hierarchical_select/hierarchical_select.module).

The issue is that _hs_process_render_create_new_item() does, in fact, attempt to pass in a non-existent configuration array into the call _hierarchical_select_create_new_item_is_allowed():

...
function _hs_process_render_create_new_item($element, $hierarchy) {
  $creating_new_item = FALSE;
  if (isset($element['#value']['hierarchical_select']['selects'])) {
    foreach ($element['#value']['hierarchical_select']['selects'] as $depth => $value) {
      if ($value == 'create_new_item' && _hierarchical_select_create_new_item_is_allowed($config, $depth)) { // Line 561
        $creating_new_item = TRUE;
...

Comments

guypaddock’s picture

Status: Active » Needs review
StatusFileSize
new811 bytes

The attached patch should correct this issue.

amaria’s picture

Thanks for the patch GuyPaddock. I received a Fatal error trying to apply it so I made the changes manually and created a new patch which works for me.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Looks almost ready. You don't need to wrap the "$value == …" check in parentheses though!

summit’s picture

Hi,

What should the correct writing for $value been please to apply this change? And can it be committed then please?
EDIT: I see it should be:

if ($value == 'create_new_item' && _hierarchical_select_create_new_item_is_allowed($element['#config'], $depth)) {

Thanks a lot in advance!
Greetings, Martijn

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

I made the necessary minor changes, then committed & pushed; I credited GuyPaddock.

http://drupalcode.org/project/hierarchical_select.git/commit/bdf5f82

mr.alinaki’s picture

Status: Fixed » Active

Have similar issue, but in line 582:
Notice: Undefined variable: config in _hs_process_render_create_new_item() (line 582 of /home/alinaki/www/htdocs/hierarchical_select/hierarchical_select.module).

Changing $config in line 582 to $element['#config'] breaks new level creation.

wim leers’s picture

Status: Active » Fixed

#6: then please open a new issue. Don't reopen fixed ones unnecessarily. Preferably, also provide a patch.

Status: Fixed » Closed (fixed)

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

yosef.homsy’s picture

Dear all even with the fix patch still receiving this error

Notice: Undefined variable: config in _hs_process_render_create_new_item() (line 583 of /var/www/html/sites/all/modules/hierarchical_select/hierarchical_select.module).

please any help

yosef.homsy’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work
yosef.homsy’s picture

this link solve the issue

yosef.homsy’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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