Download & Extend

Image field malfunctioning on embedded field collection form.

Project:Field collection
Version:7.x-1.x-dev
Component:Code
Category:bug report
Priority:major
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Problem/Motivation

When using an image field in a field collection that is added to a node form using the field collection field and the 'embed' widget, clicking the "upload" button clears the selected file from the entity instead of uploading and attaching it. If you specify a file with "choose file" but don't click upload, and then save your node, the image is attached and functions as expected. Ie the issue impacts on Ajax based uploading of image widget fields in the embedded field collection form.

Proposed resolution

Firstly update to the latest -dev versions of field_collection and entity although that most likely won't fix it.

Remaining tasks

/

User interface changes

None

API changes

None

Original report by RobW

When using an image field in a field collection, clicking the "upload" button clears the selected file from the entity instead of uploading and attaching it. If you specify a file with "choose file" but don't click upload, and then save your node, the image is attached and functions as expected.

Comments

#1

Title:Image field malfunctioning on field collection form.» Image field malfunctioning on embedded field collection form.

Forgot to mention this occurs with the embedded widget only.

#2

I can confirm this.

#3

Subscribe

#4

I think there is a general problem with images/files if modules embed the field API form not at the $form root, like profile2 and field-collection do. Maybe search for a related core-issue.

also see #1095490: Problems with files/images in the user registration form

#5

Just to add some more perspective. This was definitely *not* an issue with the earlier version of the embedded form functionality found here: http://drupal.org/node/977890#comment-4237396, but is something that we have run into since updating to the newest version of field_collection.

#6

#7

Subscribe

#8

Priority:normal» critical

Has anybody found a solution. Or are there an other widgets to use with field collection instead of the embedded widget? I need to solve this problem urgently to get field collection to work on a site that I am building for someone.

#9

Priority:critical» major

lowelhal,

You can use the other widget packaged with the module, so the issue isn't critical, but it is a pain in the ass. The other widget just hides it on the Node form and you add the field collections via the Node page.

#10

I'm now getting the following message in Chrome when I try and upload an image. The embedded form does not contain this unlimited image field, it's on a separate horizontal tab item created using the field group module.

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path:/file/ajax/field_home_slide/und/form....
StatusText:n/a
ResponseText:
Fatal Error: Call to undefinded method FieldCollectionItemEntity::setUp() in /var/www/domain/sites/all/modules/field_collection/field_collection.module on line 364
ReadyState:undefined

If I try and save the page without clicking the upload button then I still get this error:
Fatal error: Call to undefined method FieldCollectionItemEntity::setUp() in /var/www/domain/sites/all/modules/field_collection/field_collection.module on line 364

#11

Using the current dev this error[1] persits, even when switching to hidden-widget.

If I remove the image field from the field collection, I _still_ get the same error with the embedded-widget. However, the using the hidden widget, it works.

[1] Fatal error: Call to undefined method FieldCollectionItemEntity::setUp() in website\sites\all\modules\_fields\field_collection\field_collection.module on line 364

UPDATE: Using the current dev of Entity API, it looks like that: Without an image field it works with both widgets. With an image field, the hidden widget works. Embedded widget works somewhat - clicking on "upload" does not upload, but when saving the node, the image is uploaded.

Also, I stumbled across strange behavior when switching between the different widgets and adding/removing the image field to the collection. Sometimes, instances of a collection "disappeared" and "reappeared" after deleting other instances..

#12

Ok, i used the hidden widget, But would still like the user to be able to add data to the field collection fields while creating the content type. any patches or fixes to solve this problem whether it be a core problem or not?
Or any idea if successive releases will address this problem? and how soon?

#13

Subscribe

#14

Subscribe

#15

I hope this is the right place to post this. I was directed here from: http://drupal.org/node/1205670

I am having this same problem. It does not appear to matter if the upload field is actually in the field collection. I have a beta tester telling me that saving his user profile, which has two field collections, produces this error each time he makes any save at all, and yes, there is an field for a file upload. However, this field is not in the field collection.

This is the error: Exception: The host entity may be set only during creation of a field-collection item. in FieldCollectionItemEntity->setHostEntity() (line 191 of /home/host/public_html/sites/all/modules/field_collection/field_collection.module).

I am not sure this is just a pain since it renders the embed widget unusable. This widget matches how content is normally added to a page (via an edit form rather than in the node view). Is there a way to backtrack to the previous recent dev? Does anyone have a copy? This new error breaks a number of content types I set up.

#16

I hope this is the right place to post this. I was directed here from: http://drupal.org/node/1205670

I am having this same problem. It does not appear to matter if the upload field is actually in the field collection. I have a beta tester telling me that saving his user profile, which has two field collections, produces this error each time he makes any save at all, and yes, there is an field for a file upload. However, this field is not in the field collection.

This is the error: Exception: The host entity may be set only during creation of a field-collection item. in FieldCollectionItemEntity->setHostEntity() (line 191 of /home/host/public_html/sites/all/modules/field_collection/field_collection.module).

I am not sure this is just a pain since it renders the embed widget unusable. This widget matches how content is normally added to a page (via an edit form rather than in the node view). Is there a way to backtrack to the previous recent dev? Does anyone have a copy? This new error breaks a number of content types I set up.

#17

Subscribe

#18

Updating entity module to the last dev version (7.x-1.x-dev from july 7) seems to solve the issue for me.

#19

I upgraded to entity, july 7 dev. The difference is that the site no longer throws the error page to the user. However, the error is still generated, and a change in settings are not saved. Note that the change is not in a field-collection.

correction: I also updated field collection to july 7. errors gone (see http://drupal.org/node/1204428)

#20

Subscribing

I have the same behavior described on the first post (both with files & images)

In my case it only happens on the "general" create/edit form ; everything seems to work fine when I use the specific edit form of the field-collection.

Best
-P-

#21

Hum i updated to latest version both module:
Entity: 7.x-1.x-dev - 2011-Jul-12
Field collection : 7.x-1.x-dev - 2011-Jul-05

And i still have the upload box getting cleared when i click on upload.
Does it really work for you now that you uploaded both modules only? or did you change anything else? Like getting Drupal 7.4?

#22

@williamb, I already had drupal 7.4 so I didn't think it a factor. Could be wrong about that.

#23

some more details about the configuration i use :
Drupal 7.4
Entity : last dev (july 13)
Field-collection : last dev (july 5)

the behavior stays as described above..

#24

We are using Entity beta10 and the latest dev of field_collection ( July 4 ). Trying to upload an image fails, the image does not upload even when I save the collection. However, when I edit the collection record, I can upload successfully and subsequent edits don't remove the image. So it follows that the issue is in the create function for either entity or field_collection.

I haven't had a chance to dig around in the code, but I'm wondering what the difference is between the create and edit functions for those.

#25

+1. Have same problem

#26

+1

#27

Subscribe

#28

+1

#29

+1

#30

subscribe

#31

+1

#32

Has anyone made progress with this? I'm struggling where to start - and pointers?

#33

Subscribe, I've got some time to look at this one in next few days

#34

Just to add to the list, I'm seeing this behaviour on
Drupal 7.7,
Field Collection 7.x-1.x-dev (2011-Aug-11),
Entity 7.x-1.x-dev 2011-Aug-15.
I took a quick look a the post json response in firebug, but I could not see anything obviously wrong.
I also hope to get a chance to look further into this soon, has anyone made any progress yet?

#35

+1 for Field Collection 7.x-1.x-dev (2011-Aug-11),

#36

+1

#37

+1 same problem

#38

Current code is missing my fix for filefields (http://drupal.org/node/977890#comment-4233662)

At least the #value_callback is missing.

#39

@casey - looking at the patch on http://drupal.org/node/977890#comment-4233662 I see the #value_callback in the hook_field_widget_form() - but the following 'simplified' patch in http://drupal.org/node/977890#comment-4235428 does not seem to mention #value_callback. Was it then missed in following re-rolling of the patch or is it not needed for another reason? I tried adding the #vallue_callback and corresponding callback function but no joy. Any ideas?

#40

I'll look into it tomorrow (if nobody does today).

#41

@casey - awesome - I'd look into it further myself, but flat out getting ready for Drupalcon - are you coming? I'll have to buy you a beer!

#42

Status:active» needs review

On a form rebuild the collection entity is rebuild and changes are left out. I haven't spent too much time on this; there might be a cleaner solution. Looking at the old code we always were using the field collection item entity in $items. Anyways, this shows it is fixable.

@ecofinn unfortunately not, thanks for the beer though :)

AttachmentSizeStatusTest resultOperations
1187010.patch1.73 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1187010.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details

#44

@casey;

I had the same behaviour - I've just applied your patch and it's worked successfully. When I applied the patch I received a warning: warning: 1 line adds whitespace errors.

Apart from that all seems good.

Thx.

#45

#42 is working for me as well.

#46

#42 is working for me too!

#47

Status:needs review» reviewed & tested by the community

Rtbc this is one of d7s big success stories

#48

The patch in #42 works for me too. Thanks casey!

#49

#42 is not working for me - I have 7.7 core, with dev versions of field_module and entity (straight out of git).
Does this need to be applied in conjunction with another patch?

thanks

#50

Ingaro, you have to apply the patch manually.

#51

Just a reroll to remove whitespace, otherwise identical to #42. Patch still contains git credit for casey.

AttachmentSizeStatusTest resultOperations
field_collection-1187010-51.patch2.06 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch field_collection-1187010-51.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details

#52

Patch in #51 works for me when applied to 7.x-1.0-beta2

#53

#52 and I confirm #51 patch works without error

#54

patch #52 worked for me too
Thanks a lot !

-p-

#55

Status:reviewed & tested by the community» fixed

The patch looks good to me as it implements the proper form-workflow using form-state. So I committed it, thanks.

#56

Had exact same probelm. Upgraded field-collection to lastest dev version (7.x-1.x-dev) and fixed the problem. Many thanks.

#57

Status:fixed» closed (fixed)

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

nobody click here