The alter hook 'hook_inline_entity_form_table_fields_alter' provides the functionality for developers to add fields to the inline entity form table. This way, developers can add project specific fields to the table.

However, the entity reference can reference different bundles where not every bundle is required to have the same fields. When implementing hook_inline_entity_form_table_fields_alter to add a field that is not present in every bundle, the form produces a WSOD.

E.g.: The commerce_order form with widget "Inline entity form - Multiple values" for line items. A product line item with extra fields. The commerce_coupon module which adds a line item type. When implementing hook_inline_entity_form_table_fields_alter to add the extra fields from the product line item the commerce_order edit form produces a WSOD because the extra fields are not present on the coupon line item.

Inside the function theme_inline_entity_form_entity_table where the extra fields are loaded using field_view_field(), an extra check if the field exists fixes this issue.

A patch is provided in attachment.

Files: 
CommentFileSizeAuthor
#7 2074127_7.patch1.09 KBslashrsm
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 11 pass(es).
[ View ]
#4 2074127_4.patch1.09 KBslashrsm
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 11 pass(es).
[ View ]
inline_entity_form.table_fields_alter.patch645 bytesbrechtvdv

Comments

brechtvdv’s picture

Status:Active» Needs review
bojanz’s picture

Issue summary:View changes
Status:Needs review» Fixed

Status:Fixed» Closed (fixed)

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

slashrsm’s picture

Version:7.x-1.3» 8.x-1.x-dev
Status:Closed (fixed)» Needs review
Related issues:+#2472769: [META] Port 7.x commits to 8.x
StatusFileSize
new1.09 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 11 pass(es).
[ View ]

D8 port of the patch.

webflo’s picture

+++ b/inline_entity_form.module
@@ -619,7 +620,10 @@ function theme_inline_entity_form_entity_table($variables) {
+      $data = [];

Why is $data an array if the field doesn't exist? Because getString() returns a string.

webflo’s picture

Issue tags:+Media Initiative, +sprint
slashrsm’s picture

StatusFileSize
new1.09 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 11 pass(es).
[ View ]
webflo’s picture

Status:Needs review» Fixed

Looks good. Thanks!

  • webflo committed 94362ed on 8.x-1.x
    Issue #2074127 by slashrsm, brechtvdv: Unknown fields added via...