Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
* Notice : Undefined index: allowed_values in hs_taxonomy_form_field_ui_field_edit_form_alter() (line 143 in (...)/sites/all/modules/hierarchical_select/modules/hs_taxonomy.module).
* Notice : Trying to get property of non-object in hs_taxonomy_form_field_ui_field_edit_form_alter() (line 144 in (...)/sites/all/modules/hierarchical_select/modules/hs_taxonomy.module).
Steps to reproduce :
Install hierarchical_select 7.x-3.0-alpha1
Create any field save the first form, the error will show up.
Steps I followed :
created a location field in a profile2 profile type. When you save the field the error message pops up. I tried with a location field in a content type, it was the same, so it's not related to profile2.
Then I tried with a text field and the same error appears.
Comment | File | Size | Author |
---|---|---|---|
#13 | fix_undefined_index-1115498-13.patch | 1.63 KB | geerlingguy |
Comments
Comment #1
Eaglecanada CreditAttribution: Eaglecanada commentedI have the same error message. After disable the HS module, it is back to normal.
Comment #2
Hamid.D CreditAttribution: Hamid.D commentedSame problem
Comment #3
Kcannick CreditAttribution: Kcannick commentedsubscribe
Comment #4
webankit CreditAttribution: webankit commentedsame problem...
Comment #5
Jerome F CreditAttribution: Jerome F commentedThe notice now points to lines 142 and 143 in 7.x-3.x-dev
Comment #6
yugongtian CreditAttribution: yugongtian commented+1
Comment #7
SolidRock CreditAttribution: SolidRock commentedHaving the same problem. I did notice that it only appears when you *don't* use a hierarchical-select widget. If you do use the HS widget, the notice doesn't appear.
Comment #8
fietserwinWriting clear and precise titles improves searchability.
Comment #9
Jerome F CreditAttribution: Jerome F commented@fietserwin: thank you, you're right I should have done that.
@SolidRock: that's true.
Comment #10
fietserwinThe hook is executed for all fields, also non taxonomy fields. So it looks like there should be a simple check added around the code:
old:
new:
However, I have some other remarks about the code:
- Wouldn't it be better to replace require_once with module_load_include('inc', 'hierarchical_select', 'includes/common')?
- for clarity it would be better to use curly brackets in the string "taxonomy-$vocabulary->vid" : "taxonomy-${vocabulary->vid}"
So no patch, The change is easy enough, to allow the module maintainer to create it himself and at the same time incorporating (or not) my suggestions.
Comment #11
Adam S CreditAttribution: Adam S commentedSame problem. #10 fixed it.
Comment #12
ymazigo CreditAttribution: ymazigo commentedthanks.#10 fix my problem
Comment #13
geerlingguy CreditAttribution: geerlingguy commentedGit patch attached. To apply: Put patch into hs folder (not the modules subfolder), and enter in terminal:
git apply -v [patchname.patch]
.Comment #14
dafeder#13 worked for me - also, this works fine with the standard patch command
patch -p1 < fix_undefined_index-1115498-13.patch
.Comment #15
WorldFallz CreditAttribution: WorldFallz commentedsimple patch, applies cleanly, fixes the problem.
Comment #16
carwin CreditAttribution: carwin commented#13 works for me too, this should be added to the module perhaps?
Comment #17
glass.dimly CreditAttribution: glass.dimly commented+1 works for me too.
Comment #18
spessex CreditAttribution: spessex commentedTo get this to patch I had to save the patch to the modules subfolder of HS and then apply the patch by issuing the following command:
cd [space] then file path of modules subfolder - just drag and drop from finder into terminal.
in my example:
cd /Applications/MAMP/htdocs/mrfgr/sites/all/modules/hierarchical_select/modules
followed by:
patch < fix_undefined_index-1115498-13.patch
This then works.
Comment #19
Wim Leers@fietserwin: solid suggestions, but:
1) I don't know if there was a particular reason for me to do this: maybe it's a leftover from the D5 days, maybe it's because module_load_include() is not available in AJAX calls — I don't remember. Hence, I will not make this change right away, but I welcome a patch that does this (in a separate issue).
2) Personally, I don't think it's particularly more legible that way — maybe it depends on your editor's syntax highlighting?
@spessex: alternatively, you could just use `git apply
Committed the patch in #13 by geerlingguy: http://drupalcode.org/project/hierarchical_select.git/commit/d6b991a
Comment #20
fietserwinHmmm, I'm still getting the 2nd notice:
Notice: Trying to get property of non-object in hs_taxonomy_form_field_ui_field_edit_form_alter() (line 144 of D:\Projecten\Maisonnera\public_html\sites\all\modules\hierarchical_select\modules\hs_taxonomy.module).
It turns out there are fields that have $form['#field']['settings']['allowed_values'][0] set, and that contain a string (fields with type = list_integer). So $form['#field']['settings']['allowed_values'][0]['vocabulary'] will then return the first character of that string, which is set...
I think it will be better to check on the type of the field:
Comment #21
Wim LeersGood catch. Committed your suggestion: http://drupalcode.org/project/hierarchical_select.git/commit/e14b895. Thanks again!