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.
Comment | File | Size | Author |
---|---|---|---|
#7 | 2074127_7.patch | 1.09 KB | slashrsm |
#4 | 2074127_4.patch | 1.09 KB | slashrsm |
inline_entity_form.table_fields_alter.patch | 645 bytes | brechtvdv | |
Comments
Comment #1
brechtvdv CreditAttribution: brechtvdv commentedComment #2
bojanz CreditAttribution: bojanz commentedCommitted something similar:
http://drupalcode.org/project/inline_entity_form.git/commitdiff/37959cc
Comment #4
slashrsm CreditAttribution: slashrsm at Examiner.com commentedD8 port of the patch.
Comment #5
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedWhy is $data an array if the field doesn't exist? Because getString() returns a string.
Comment #6
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedComment #7
slashrsm CreditAttribution: slashrsm as a volunteer commentedComment #8
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedLooks good. Thanks!