The current code has two problems:
1) The column label logic was never ported, so the label/bundle columns are always called "Label" and "Type"
2) The label field doesn't invoke $entity->label(), therefore showing the wrong label when the entity has a label callback or any custom logic on the class itself.
3) The whole fallback to id only made sense in D7 cause many entity types didn't have labels in the beginning. In D8 all entity types have labels.

Solution:
Kill the id fallback, port the column label logic, introduce a special IEF field type that calls $entity->label().

Patch incoming.

Comments

bojanz created an issue. See original summary.

bojanz’s picture

Status: Active » Needs review
StatusFileSize
new2.74 KB

Initial patch attached.

Still running tests, they might need an update.

This fixes the issue I have with product variations, which don't have a label key, but have a label() which builds a label based on other fields.

Status: Needs review » Needs work

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

bojanz’s picture

Status: Needs work » Needs review
StatusFileSize
new6.57 KB

Updated the tests, since the column is now always called "label", the classes changed.

Status: Needs review » Needs work

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

bojanz’s picture

Status: Needs work » Needs review
StatusFileSize
new6.54 KB

Third time's the charm.

I should mention my reasoning for making "label" always the key of the column, instead of using the label key when available:
When it comes to fields, labels are special because they might not be backed by an actual field, they might be dynamically generated.
The fixed column key emphasises this, as well as the fact that the source of the data is not a rendered field, but $entity->label() instead.

slashrsm’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

  • bojanz committed ac419fd on 8.x-1.x
    Issue #2612070 by bojanz: Rework EntityInlineEntityFormHandler::...
bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks for the review.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

Status: Fixed » Needs work

The last submitted patch, 14: 2612070-3-fix-tablefields.patch, failed testing.

The last submitted patch, 14: 2612070-3-fix-tablefields.patch, failed testing.

The last submitted patch, 14: 2612070-3-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 14: 2612070-3-fix-tablefields.patch, failed testing.

The last submitted patch, 14: 2612070-3-fix-tablefields.patch, failed testing.

bojanz’s picture

Status: Needs work » Fixed

What the..

brockfanning’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Fixed » Needs review
StatusFileSize
new2.27 KB

I'm still in D7-world, and needed this, so here is a patch to get #2 (in the issue description) working in D7.

Status: Needs review » Needs work

The last submitted patch, 34: inline_entity_form-fix_tablefields_d7-2612070-34.patch, failed testing.

The last submitted patch, 34: inline_entity_form-fix_tablefields_d7-2612070-34.patch, failed testing.

The last submitted patch, 34: inline_entity_form-fix_tablefields_d7-2612070-34.patch, failed testing.

The last submitted patch, 34: inline_entity_form-fix_tablefields_d7-2612070-34.patch, failed testing.

Status: Needs work » Needs review

The last submitted patch, 2: 2612070-1-fix-tablefields.patch, failed testing.

The last submitted patch, 8: 2612070-2-fix-tablefields.patch, failed testing.

The last submitted patch, 14: 2612070-3-fix-tablefields.patch, failed testing.

brockfanning’s picture

Status: Needs review » Needs work

The last submitted patch, 34: inline_entity_form-fix_tablefields_d7-2612070-34.patch, failed testing.

brockfanning’s picture

I don't know what's going on with the tests... But this is ready for review, in my opinion.

dcam’s picture

Status: Needs work » Closed (outdated)

Since Drupal 7 is now end-of-life I am closing some old issues for the 7.x branch of this module. If this issue is still relevant for the 3.x branch of the module, then feel free to reopen it.