Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in _multiselect_build_widget_code() (line 181 ....\multiselect\multiselect.module).
Issue:
_multiselect_build_widget_code() does not check for nid
fix by adding:
elseif (array_key_exists($value['nid'], $options)) { // With FAPI, it's not.
$selected_options[$value['nid']] = $options[$value['nid']];
Comments
Comment #1
Svekke commentedComment #2
Svekke commentedComment #3
Frogtown commentedConfirming this -- I am using this as a node reference, built from a view, after going back into the edit node form, I get the error: Warning: array_key_exists(): The first argument should be either a string or an integer in _multiselect_build_widget_code() (line 181 of /home/httpd/pages/sites/all/modules/multiselect/multiselect.module). --- And the selected node reference values have been reset.
Comment #4
jvandooren commentedCan you give the patch a try and let us know if it worked for you?
Comment #5
Frogtown commentedI applied the patch, and it seems to have resolved the issue. The values are still selected when going into the node edit form, and I am no longer getting the whole "Array key exists" error. I've tested it in a few other ways, removing, re-adding values, resaving, etc. And it seems to be stable now. Would be great if anyone else can confirm this, and hopefully implement it into the next stable release.
Comment #6
clemens.tolboomAccording to #5 this works for nodes.
But what about references to other entities like users?
Set to needs work with a '?'
Comment #7
Svekke commentedThis is only a patch for nodes.
You can add a new patch for the user reference.
Comment #8
clemens.tolboomThis is not a patch for nodes as after applying this patch it will ignore user references as
With FAPI means probably all others such as node and user references
Comment #9
comfreak commentedif you add
it works for user references and node references as well.
Comment #10
internetdevels commentedI am using module Entity Referece. I've got the same error when I wanted to apply multiselect widget to my entity reference field . The solution is shown in first patch (multiselect_array_keys_exists_entity_reference).
More flexible solution which includes references of all entities (node, user, term references) is shown in second patch (multiselect_array_whichexists_entity_reference_2). Module version is 7.x-1.x-dev (2011-Mar-07).
Also Entity Reference module can be included to multiselect_field_widget_info. Because for using multiselect widget for entity reference field I added
to custom module.
Comment #11
internetdevels commentedLittle fixes to patches above
Comment #12
clemens.tolboom@InternetDevels.Com I like your second solution.
What I wonder is whether the code
Isn't this obsolete as fields are in core?
Comment #13
emptyvoid commentedIn order for the patches to appear in the entity management pages you have to register the "entityreference" field type both in:
multiselect_form_alter()
multiselect_field_widget_info()
Comment #14
emptyvoid commentedCreated a combined patch from #11 (http://drupal.org/node/1330256#comment-5450838) and the additional registration changes I mention in my previous comment.
Now the multiselect appears as a display option for fields in any entity.
Comment #15
jdleonardThis appears to be fixed in the dev releases.