FieldInstance::delete() removes the instance from EntityDisplays for all view modes, but only for the 'default' form mode

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

It would really helpful to have a helper to list modes per entity type

yched’s picture

Issue tags: +Field API

tagging

swentel’s picture

Status: Active » Needs review
FileSize
1.07 KB

This should do it. Will look for tests later, because it seems the entity display tests are actually not working properly.

swentel’s picture

FileSize
956 bytes
2.58 KB
2.43 KB

Some additional tests first for entity display because they were passing without knowing. I've added an explicit check to see whether the component exists or not. Interdiff is between fail and pass.

swentel’s picture

FileSize
5.92 KB

And now with form display tests too. Note that I've added a form mode alter in entity_test module so I could test multiple form modes.

yched’s picture

Thanks, looks correct. Just nitpicks on visual review:

+++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.phpundefined
@@ -255,19 +255,32 @@ public function testDeleteFieldInstance() {
+    // Check the components exists.

Minor: plural / singular mismatch (same in the other class)

+++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.phpundefined
@@ -119,4 +119,51 @@ public function testFieldComponent() {
+  }

Minor: missing empty line after last method.

swentel’s picture

FileSize
1.7 KB
5.84 KB

Cleaned up.

Status: Needs review » Needs work

The last submitted patch, 2041225-7.patch, failed testing.

swentel’s picture

Status: Needs work » Needs review
FileSize
690 bytes
5.87 KB

Ah, entity storage of course.

yched’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!
RTBC if green.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 477cb6e and pushed to 8.x. Thanks!

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