function hook_ENTITY_TYPE_form_mode_alter
Same name in other branches
- 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_form_mode_alter()
Change the form mode of a specific entity type currently being displayed.
Parameters
string $form_mode: The form_mode currently displaying the entity.
\Drupal\Core\Entity\EntityInterface $entity: The entity that is being viewed.
Related topics
1 function implements hook_ENTITY_TYPE_form_mode_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- entity_test_entity_test_form_mode_alter in core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module - Implements hook_ENTITY_TYPE_form_mode_alter().
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1890
Code
function hook_ENTITY_TYPE_form_mode_alter(string &$form_mode, \Drupal\Core\Entity\EntityInterface $entity) : void {
// Change the form mode for nodes with 'article' bundle.
if ($entity->bundle() == 'article') {
$form_mode = 'custom_article_form_mode';
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.