warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /home/xxx/public_html/travellocal/modules/cck/modules/optionwidgets/optionwidgets.module on line 318.

I get the above on 1.0-alpha when trying to create a text field with a drop-down containing a number of options.

Comments

coltrane’s picture

I get the same error on 6.x-1.0-dev as well. I'm in the process of trying to debug this and so far I've narrowed it down to optionwidgets_data2form() returning:

[#value] => Array
        (
            [value] => 
        )

when it should be

[#value] => Array
        (
            [value] => Array
                (
                )

        )

The latter is what the $element contains when using an on/off text field, using the buttons returns an empty element in #value which causes the PHP error.

coltrane’s picture

Version: 6.x-1.0-alpha » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new370 bytes

Here's a patch against 6.x-1.x-dev that corrects the PHP warning.

The problem was in optionwidgets_data2form(). The reset() returns FALSE if the array is empty, which it is, but we need an empty array, not false when the field is first added.

This might not be the best fix but I'm not able to dive deeper into the code at the moment.

coltrane’s picture

http://drupal.org/node/241691 was marked a duplicate of this

karens’s picture

Status: Needs review » Fixed

I couldn't create a situation that produced this error, but I can see that the possibility exists, so I've committed the patch. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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