Hello,

I recently upgraded to Drupal 7.15. Since then, when I try to add a new authenticated user, I get the following error message appearing on the 'add new user' interface.

Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value() (line 2284 of /home5/mywebsite/public_html/includes/form.inc)

The site lets me create a new user but repeats the error message after I save the user info. I end up getting two identical error messages in a box at the top of the page.

Does anyone know what might be causing this?

Thanks in advance,

M

Comments

head’s picture

same problem

lilbebel’s picture

Hello,

I have found a fix thanks to Aethr at: http://drupal.org/node/1527006

#4
Posted by aethr on July 2, 2012 at 1:30am

This appears to be caused by metatags_quick_checkboxes widget which is used for the robots field. In the Drupal Forms API the '#default_value' for a 'checkboxes' form element must be an array of the "checked" options.

In the function metatags_quick_field_widget_form it appears to be trying to assign a default value for the checkboxes field based on the "default_value" of the instance. However, on a clean install the instance has no "default_value" set, which results in the checkbox form element getting a default value of NULL.

However, when the Form API attempts to process this element, it expects an array. When '#default_value' is set to NULL (instead of an empty array) it results in the "invalid foreach" error message which is being reported by the users above.

Without knowing much about this module, I'm hesitant to provide a patch. However I'd say that a simple fix would be pre-populating the "default value" for this field at creation with an empty array. Alternatively a check could be placed in metatags_quick_field_widget_form such that if a NULL value is detected in the '#default_value' of a checkbox element, it is re-initialised to an empty array.

A simple fix in the meantime is to open the Manage Fields admin page for each content type with the (Meta)Robots field attached, and click "edit field" for (Meta)Robots. At the bottom of the Edit Fields page, simply hit the Save settings button. This will populate a properly formatted default value for the field and the error will go away for that content type.

This step must be repeated for all content types that use the (Meta)Robots field.

Many thanks!

lilbebel’s picture

Status: Active » Closed (fixed)