warning: Invalid argument supplied for foreach() in \sites\all\modules\i18n\i18nsync\i18nsync.module on line 74.

possible fix :

if (!empty($data['#options'])) {
foreach ($data['#options'] as $field => $name) {
$form['workflow']['i18n']['i18nsync_nodeapi'][$field] = array(
'#group_title' => $title,
'#title' => $name,
'#type' => 'checkbox',
'#default_value' => in_array($field, $current),
'#theme' => 'i18nsync_workflow_checkbox',
);
$title = '';
}
}

Comments

errement’s picture

Status: Patch (to be ported) » Active

I am having same problem:
warning: Invalid argument supplied for foreach() in ../sites/all/modules/i18n/i18nsync/i18nsync.module on line 74.

It shows when i go "admin/content/types" and choose any type, the wierd thing is that it doesn't show when i select the "Story" content type.

Shows on:
-FAQ
-Page
-Poll
-Recipe
-Webform

Doesn't show on:
-Story

Any help?
Any idea why is it showing?
I am new!!

Aldus’s picture

I also have this problem. Has someone tried the fix above?

errement’s picture

Status: Active » Needs work

@gattoplano,

I did, you?
Anybody else??

vjacquin on #1 (where are you vjacquin) gave us this:

if (!empty($data['#options'])) {
foreach ($data['#options'] as $field => $name) {
$form['workflow']['i18n']['i18nsync_nodeapi'][$field] = array(
'#group_title' => $title,
'#title' => $name,
'#type' => 'checkbox',
'#default_value' => in_array($field, $current),
'#theme' => 'i18nsync_workflow_checkbox',
);
$title = '';
}
}

And the result = BLANK screen, i wonder why?!

He forgot to write "}" at the end!!
So it should be:

Index: i18nsync.module
===================================================================
file: …/modules/i18n/i18nsync/i18nsync.module

@@ 70 @@ function i18nsync_form_alter(&$form, $form_state, $form_id) {

<?php
      // Each set provides title and options. We build a big checkboxes control for it to be
      // saved as an array. Special themeing for group titles.
      foreach (i18nsync_node_available_fields($type) as $group => $data) {
        $title = $data['#title'];
+     if (!empty($data['#options'])) {
        foreach ($data['#options'] as $field => $name) {
          $form['workflow']['i18n']['i18nsync_nodeapi'][$field] = array(
            '#group_title' => $title,
            '#title' => $name,
            '#type' => 'checkbox',
            '#default_value' => in_array($field, $current),
            '#theme' => 'i18nsync_workflow_checkbox',
          );
          $title = '';
        }
      }
+   }
      break;
  }
}

/**
 * Theming function for workflow checkboxes
 */
?>

Just add "}" and his "patch" will work!! with no warnings.
Somebody should review it and respond here!!

Anyway, something happens with either FAQ, Poll, Recipe or Webform as this only happens —to me— with them enabled. My other dev sites have no warnings —also have no FAQ, Poll, Recipe or Webform modules enabled—. I have no time to try to search what happens, but if somebody do, start with these modules!

Cheers!!

grub’s picture

I get the same error and of the modules you mentioned I only have FAQ installed, so perhaps that is where to look. Thanks for the patch and fix, works fine here using i18n 6.x-1.0-beta3.

portulaca’s picture

thank you errement, your patch removes the error message

jose reyero’s picture

Status: Needs work » Fixed

Thanks

errement’s picture

@ all ppl,

This is not my patch, it's from vjacquin (who created this issue, i think) don't know where is he??
and i wonder why doesn't he pass by to say something.

What i did is just make it easier for all of us to read with highlighted PHP tags!! and add the "}" at the end.

This is new for me, but i start to like. Drupal is huge!!
;-))

N.B.: Thank you Jose A Reyero for your GREAT modules!! I appreciate, a lot!!

vjacquin’s picture

I'm back !
I'm happy it helped.
Cya

Anonymous’s picture

Status: Fixed » Closed (fixed)

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