By phthlaap on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.3.x
Introduced in version:
10.3.0
Issue links:
Description:
New hook hook_ENTITY_TYPE_form_mode_alter() has been added to allow modules implement form mode alter hook for only specific entity types.
For Usage, the module developers have to replace ENTITY_TYPE with node, user etc. Examples below:
Before
function example_entity_form_mode_alter(&$form_mode, \Drupal\Core\Entity\EntityInterface $entity) {
if ($entity->getEntityTypeId() == 'node' && $entity->bundle() == 'article') {
$form_mode = 'custom_article_form_mode';
}
}After
function example_node_form_mode_alter(string &$form_mode, \Drupal\Core\Entity\EntityInterface $entity) {
if ($entity->bundle() == 'article') {
$form_mode = 'custom_article_form_mode';
}
}Impacts:
Module developers
Themers
Site templates, recipes and distribution developers