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...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Status: Active » Postponed (maintainer needs more info)

> (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.

Demoshane’s picture

I 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...

joachim’s picture

Is 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?

joachim’s picture

> 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.

Demoshane’s picture

I'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.

joachim’s picture

> 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!!

joachim’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
2.92 KB

I 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.

joachim’s picture

Issue summary: View changes

Be nice if the testbot could take a look at it at least... seems to be stuck!

joachim’s picture

Trying again with a filename without extra dots, per suggestion on IRC.

Status: Needs review » Needs work

The last submitted patch, 9: 1967392-editableviews-bogus-entity-creation copy.patch, failed testing.

joachim’s picture

Status: Needs work » Fixed

Huh. Looks like I commited this ages ago!

Status: Fixed » Closed (fixed)

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