Hello all.

I using drupal 7.12 and field collection 7.x-1.0-beta4.
I will describe my problem as bellow :

I create a new content type. Next I add a field collection field and put an image field and a text field inside a the field collection.
After that I create add new content to the new contain type. When i upload image to the image field, there are two warnings as bellow:
Warning: Invalid argument supplied for foreach() in file_field_widget_submit() (line 760 of /var/www/drupal7/modules/file/file.field.inc).
Warning: array_values() expects parameter 1 to be array, null given in file_field_widget_submit() (line 767 of /var/www/drupal7/modules/file/file.field.inc).

May I know how to fix this problem since this is field collection module is very important to my project.

Thanks in advance.

Comments

indigoxela’s picture

Hi tyx,
I would say, your problem ist related to http://drupal.org/node/1329856 (beta3).
That bug is not fixed yet in field collection 7.x-1.0-beta4 and as far as I know, there is no patch available for beta4.

These issues are also related to http://drupal.org/node/1468686, but it guess they should be fixed in field_collection first and we should avoid to patch around in core.

drupa11y’s picture

With Drupal 7.14 I get this error when I select a multimedia widget image:
Fatal error: Call to undefined function file_entity_file_is_local() in /Applications/MAMP/htdocs/thezooproject/sites/default/modules/media-modules/media/modules/mediafield/mediafield.module on line 198

drupa11y’s picture

Another error I get now:

Fatal error: Call to undefined function entity_i18n_string() in /Applications/MAMP/htdocs/thezooproject/sites/default/modules/cck-modules/field_collection/field_collection.module on line 869

drupa11y’s picture

Problem of this error is that several modules need an exact combination.
More on this topic is in the "media"-file issue list here: http://drupal.org/node/1516804

For media 1.0 it turns out that the file_entity module was installed and it was conflicting with media module.
For media 2.x the latest devs are necessary: file_entity 7.x-2.x-dev & media 7.x-2.x-dev

Thread "field collection dev requires entity api dev version": http://drupal.org/node/1471840

Thread for "Undefined function entity_i18n_string()": http://drupal.org/node/1448594
Thread in media "Call to undefined function file_entity_file_is_local": http://drupal.org/node/1516804

Hope this helps solving some issues.

donpwinston’s picture

Priority: Normal » Major

I'm using a "field collection" field as an embedded widget. The image field gives the following warnings when used in my form. These errors do not occur when I use an image field in the normal way. It still "works" but the warnings are not acceptable.

Warning: Invalid argument supplied for foreach() in file_field_widget_submit() (line 760 of /Users/satchwinston/Sites/drupal7/modules/file/file.field.inc).
Warning: array_values() expects parameter 1 to be array, null given in file_field_widget_submit() (line 767 of /Users/satchwinston/Sites/drupal7/modules/file/file.field.inc).

Please fix this or tell me how to fix it.

donpwinston’s picture

Obviously the same thing happens with the file widget

blueminds’s picture

field_collection unsets some values from $form_state array which results in this error. It is done in the field_collection_field_widget_embed_validate() function on lines 1288, 1289. Problem arises because FAPI validation expects following parents:
field_images, und, 0, field_gallery_image, und
however these are provided:
field_images, und, 0, entity

To fix it add following code on the line 1280:
$item = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
to remain former items in the array.

donpwinston’s picture

Thanks. That appears to work.

blueminds’s picture

Status: Active » Needs review

see #7

fago’s picture

Status: Needs review » Needs work

Please roll a proper patch file.

puppyman’s picture

hooray #7

j-phat’s picture

#7 says to add the line in line 1280 but i only have a total of 1015 lines in the file.field.inc file

drupal 7.14
Field collection 7.x-1.0-beta4

blueminds’s picture

#12 - wrong module, wrong file. Go for file field_collection.module in the field_collection module.

blueminds’s picture

Status: Needs work » Needs review
StatusFileSize
new710 bytes

the patch for #7

Goekmen’s picture

Thanks for the patch, working for me!

yannickoo’s picture

Yes! Thanks for the patch, works. Can we mark this issue as RTBC?

dmtrfoxerr’s picture

dmtrfoxerr’s picture

Thanks for the patch, works.

ChrisConolly’s picture

I've applied this patch to field_collection 7.x-1.0-beta4 using drupal 7.14 and I still have the same problem. The image does upload but it seems to get lost and none of the imagecahce presets generate for it.

Any other ideas?

**Edit**

Sorry, I was too quick to assume this was the problem (it was a problem I had when dev'ing). Turns out the client's being messing around with their server setup and that broke it.

star-szr’s picture

Status: Needs review » Reviewed & tested by the community

Sounds like we have pretty good consensus and the patch looks reasonable.

fago’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, I've added a comment explaining it and committed it.

kris-o3’s picture

the line number didn't quite match my version of field_collection.module but i was able to find where to apply this patch...

worked for me!

Status: Fixed » Closed (fixed)

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

kris-o3’s picture

ran into this problem as well... field_collection beta4...

the patch in #14 appears to have resolved the issue.