function hook_ENTITY_TYPE_form_mode_alter
Same name and namespace in other branches
- 10 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
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1923
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.