Problem/Motivation

Since we have a confirmation on hook_ENTITY_TYPE_view_mode_alter(), it is reasonable (and consistent) to add the hook_ENTITY_TYPE_form_mode_alter() as well.

Upon examining \Drupal\Core\Entity\Entity\EntityFormDisplay::collectRenderDisplay#L90 we can observe that the entity_form_mode hooks are only invoked, confirming that the desired hook does not exist.

Steps to reproduce

N/A

Proposed resolution

Add the new hook.

Remaining tasks

User interface changes

N/A

API changes

Introducing a new entity hook named hook_ENTITY_TYPE_form_mode_alter() to "Change the form mode of a specific entity type for building an entity form."

Data model changes

N/A

Release notes snippet

TBD

Issue fork drupal-3419186

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

balintpekker created an issue. See original summary.

ruturaj chaubey’s picture

Assigned: Unassigned » ruturaj chaubey

ruturaj chaubey’s picture

Assigned: ruturaj chaubey » Unassigned
Issue tags: +Needs tests
ruturaj chaubey’s picture

Status: Active » Needs review
Issue tags: -Needs tests
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Tests tag was correct.

phthlaap made their first commit to this issue’s fork.

phthlaap’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests +Needs Review Queue Initiative
1) Drupal\Tests\system\Functional\Entity\EntityFormTest::testEntityFormModeAlter
Behat\Mink\Exception\ExpectationException: An element matching css "input[name="field_test_text[0][value]"]" appears on this page, but it should not.
/builds/issue/drupal-3419186/vendor/behat/mink/src/WebAssert.php:888
/builds/issue/drupal-3419186/vendor/behat/mink/src/WebAssert.php:492
/builds/issue/drupal-3419186/core/modules/system/tests/src/Functional/Entity/EntityFormTest.php:117
/builds/issue/drupal-3419186/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
ERRORS!
Tests: 6, Assertions: 166, Errors: 1.

Removing tests tag. Good job extending an existing test

CR reads fine also

  • catch committed e1dc7a71 on 10.3.x
    Issue #3419186 by Ruturaj Chaubey, phthlaap, balintpekker, smustgrave:...

  • catch committed 386e810b on 11.x
    Issue #3419186 by Ruturaj Chaubey, phthlaap, balintpekker, smustgrave:...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!

Status: Fixed » Closed (fixed)

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