function entity_get_render_form_display

Returns the entity_form_display object used to render an entity form.

This function should only be used internally when rendering an entity form. When assigning suggested form display options for a component in a given form mode, entity_get_form_display() should be used instead, in order to avoid inadvertently modifying the output of other form modes that might happen to use the 'default' form display too. Those options will then be effectively applied only if the form mode is configured to use them.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which the form is being rendered.

string $form_mode: The form mode being rendered.

Return value

\Drupal\entity\Plugin\Core\Entity\EntityFormDisplay The form display object that should be used to render the entity form.

See also

entity_get_form_display().

2 calls to entity_get_render_form_display()
EditFieldForm::init in drupal/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
Initialize the form state and the entity before the first form build.
EntityFormController::init in drupal/core/lib/Drupal/Core/Entity/EntityFormController.php
Initialize the form state and the entity before the first form build.

File

drupal/core/includes/entity.inc, line 788
Entity API for handling entities like nodes or users.

Code

function entity_get_render_form_display(EntityInterface $entity, $form_mode) {
  $entity_type = $entity
    ->entityType();
  $bundle = $entity
    ->bundle();

  // @todo Form modes don't have custom settings yet, so just return the display
  // for the form mode that was requested.
  $form_display = entity_get_form_display($entity_type, $bundle, $form_mode);
  $form_display->originalMode = $form_mode;
  return $form_display;
}