After installing Meta Tag Quick 7.x-2.4 I have the follwing warning when editing a Meta Tag Quick enabled content.

Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value() (Zeile 2251 von /var/www/domains/less.ch/less-v4/includes/form.inc).

Files: 

Comments

I am getting a similar warning
Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value() (line 2251 of ... my website path.. /includes/form.inc).
So far this seems to occur on panel pages when I first enter the path-based meta tag form - once I fill it in and save if I go back in to renter info there is no warning.

As I remeber the warning was showed on every page (panels, pages, articles etc.). After filling in some m eta-content the warning disappeared.

Raffaele

Yeah, same issue here. I traced the problem back to just the meta_robots field (although not much further)--it goes away if you pull that field off of a content type. Note: this problem also renders nodes inoperable by Views Bulk Operations. Which is how I found out about all this.

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.

StatusFileSize
new843 bytes

Here is a patch that fix this error.

StatusFileSize
new858 bytes

I've accidently removed usefull lines.
Sorry about that.

Version:7.x-2.4» 7.x-2.x-dev

I think Drupal fills values with empty strings, not zeros.
Shouln't
array_fill_keys($default_checkboxes, '');
fit better?

This is still popping up in 7.x-2.5. Is there a preferred patch solution given comments in #6, #7.

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

Probably worth mentioning i've tried the latest dev version as well. Despite running update.php and applying the update it's still there. Cleared caches and run cron as well.

Could you just confirm valthebald that #6 is good to use for now, for myself and others finding this issue.

Many thanks.

#9: yes, patch from #6 is perfectly usable. I just wanted it to be slightly better to commit

Super. Applied patch in #6 as a temp fix. No more

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

If you're not happy with the patch could you apply a more satisfactory one to dev version valthebald ?

Status:Active» Fixed

Fixed in 7.x-2.x-dev

Status:Fixed» Closed (fixed)

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