function entity_get_form_display
Returns the entity form display associated with a bundle and form mode.
The function reads the entity form display object from the current configuration, or returns a ready-to-use empty one if no configuration entry exists yet for this bundle and form mode. This streamlines manipulation of entity form displays by always returning a consistent object that reflects the current state of the configuration.
Example usage:
- Set the 'body' field to be displayed with the 'text_textarea_with_summary' widget and the 'field_image' field to be hidden on article nodes in the 'default' form mode.
entity_get_form_display('node', 'article', 'default')->setComponent('body', array(
'type' => 'text_textarea_with_summary',
'weight' => 1,
))
->setComponent('field_image', array(
'region' => 'hidden',
))
->save();
Parameters
string $entity_type: The entity type.
string $bundle: The bundle.
string $form_mode: The form mode.
Return value
\Drupal\Core\Entity\Display\EntityFormDisplayInterface The entity form display associated with the given form mode.
Deprecated
in drupal:8.8.0 and is removed from drupal:9.0.0. Use EntityDisplayRepositoryInterface::getFormDisplay() instead.
See also
https://www.drupal.org/node/2835616
\Drupal\Core\Entity\EntityStorageInterface::create()
\Drupal\Core\Entity\EntityStorageInterface::load()
1 call to entity_get_form_display()
- EntityLegacyTest::testLegacyDisplayFunctions in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityLegacyTest.php - @expectedDeprecation entity_get_display() is deprecated in drupal:8.8.0. It will be removed before drupal:9.0.0. Use \Drupal::service('entity_display.repository')->getViewDisplay() instead. Seeā¦
File
-
core/
includes/ entity.inc, line 482
Code
function entity_get_form_display($entity_type, $bundle, $form_mode) {
@trigger_error('entity_get_form_display() is deprecated in drupal:8.8.0. It will be removed before drupal:9.0.0. Use \\Drupal::service(\'entity_display.repository\')->getFormDisplay() instead. See https://www.drupal.org/node/2835616', E_USER_DEPRECATED);
return \Drupal::service('entity_display.repository')->getFormDisplay($entity_type, $bundle, $form_mode);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.