Warning: Invalid argument supplied for foreach() in editableviews_entity_form_submit_build_values() (line 233 of /home/hopetapa/public_html/sites/all/modules/editableviews/editableviews.module).
When saving a view that has editable entity reference it occasionally saves new entity of referenced type (and subtype that does not even exist). These new entities must be deleted via database.
My usage. I have a node that has entity ref field to commerce coupon and a view that lists nodes of that type with editable entity ref field to coupon. If I assign coupon code via entity reference field following error occurs without changes getting saved and it informs me that new coupon of type has been created (which is empty and is not visible with coupon listings, this must be deleted via mysql).
https://www.evernote.com/shard/s61/sh/e1f9071c-c078-4374-a3aa-7bfb7cb07a...
https://www.evernote.com/shard/s61/sh/5bcb8354-808d-4a3f-8fa9-a54ec4a629...
Comment | File | Size | Author |
---|---|---|---|
#9 | 1967392-editableviews-bogus-entity-creation copy.patch | 2.92 KB | joachim |
#7 | 1967392.editableviews.bogus-entity-creation.patch | 2.92 KB | joachim |
Comments
Comment #1
joachim CreditAttribution: joachim commented> (and subtype that does not even exist). These new entities must be deleted via database.
I'm not sure how that's possible. Have you checked the settings on the Editable table? The subtype of the created entities is taken from that.
In general, new entities are saved if they have values in their fields.
Do your fields have default values? If so, entities will always be created.
Comment #2
Demoshane CreditAttribution: Demoshane commentedI managed to isolate the problem. It happens only when entity reference field has value - None -.
Workflow:
Create node type of sponsor request (Coupon code by default is none). Have a view that has editable node reference field and save view when one of the records have entity reference field set as - None -. What follows is that it creates coupon entity that get's coupon type that equals to node type that references the coupon.
Maybe view could do comparison check so that it only tries to create entities that have their values changed? On the other hand this wouldn't prevent this from happening if someone changes from coupon code to to - None - as for some reason it tries to create referenced entity type when it is set to - None -. I have no clue why it decides to use content_type for coupon type as a value.
Settings:
https://www.evernote.com/shard/s61/sh/cdf57229-13ba-470b-a534-6abb9cdb05...
Comment #3
joachim CreditAttribution: joachim commentedIs the entity that is referenced participating in the view?
Can you reproduce this problem with core entities (eg, node, taxonomy terms) and export your view?
Comment #4
joachim CreditAttribution: joachim commented> I have no clue why it decides to use content_type for coupon type as a value.
Check the bundle type settings in the editable table admin.
Comment #5
Demoshane CreditAttribution: Demoshane commentedI'll build sandbox installation when I manage to arrange some time. If you mean by bundle type settings the bundle type settings that should appear when editing editable table settings within view, they don't appear with this views (Noticed them on other view I was playing with on the other hand). I'll reply when I have more to tell.
Comment #6
joachim CreditAttribution: joachim commented> If you mean by bundle type settings the bundle type settings that should appear when editing editable table settings within view, they don't appear with this views
I mean the 'Relationship entity creation bundles' bit.
If you don't have them, is that because your view does not have relationships?
In which case, there's definitely a problem -- a view with no relationships shouldn't create entities at all!!
Comment #7
joachim CreditAttribution: joachim commentedI think I've found the problem.
Could you try this patch please? You'll need to get the latest version of the code from git to apply it.
Comment #8
joachim CreditAttribution: joachim commentedBe nice if the testbot could take a look at it at least... seems to be stuck!
Comment #9
joachim CreditAttribution: joachim commentedTrying again with a filename without extra dots, per suggestion on IRC.
Comment #11
joachim CreditAttribution: joachim commentedHuh. Looks like I commited this ages ago!