Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Currently, if you create bundle with name equal to entity type (for example, create content type = "node"), the node form id will be 'node_form' instead of 'node_node_form'.
Proposed resolution
Change logic in Drupal\Core\Entity\EntityForm::getFormId() line 78:
if ($bundle != $entity_type) {
Remaining tasks
write tests
User interface changes
No.
API changes
No.
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff.txt | 581 bytes | andypost |
#11 | 2279071-entity-form-id-11.patch | 3.53 KB | andypost |
#11 | 2279071-entity-form-id-11-fail.patch | 2.73 KB | andypost |
Comments
Comment #1
andypostSeems we have no tests at all
Comment #2
andypostI think no reason in tests
Comment #3
andypostTest should make sure the proper name for for form when bundle name is the same as entity type name
Comment #4
BerdirShould be possible to use the entity_test form for that, the default bundle there is entity_test and it has a bundle key.
Comment #5
tim.plunkettThis absolutely needs tests. It should be easy enough to write a unit test for this, right?
It should cover both entity types with and without a bundle key.
The change looks fine.
Comment #6
andypostHere's a unit test
Comment #8
tim.plunkettLooks good to me, thanks @andypost!
Comment #9
alexpottThere is no test where the entity and bundle have the same name?
Comment #10
andypostThe failed test shows the case:
this is the case, because the test uses Entity and it's method bundle() returns entity name
Comment #11
andypostAdded case for user with bundle user.
Now fail test shows 3 failures (1 user bundle and 2 for empty bundle)
Comment #13
webchickCommitted and pushed to 8.x. Thanks!