class EntityViewDisplayEditForm
Edit form for the EntityViewDisplay entity type.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase implements \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Routing\LinkGeneratorTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\Routing\UrlGeneratorTrait
- class \Drupal\Core\Entity\EntityForm implements \Drupal\Core\Entity\EntityFormInterface extends \Drupal\Core\Form\FormBase
- class \Drupal\field_ui\Form\EntityDisplayFormBase extends \Drupal\Core\Entity\EntityForm
- class \Drupal\field_ui\Form\EntityViewDisplayEditForm extends \Drupal\field_ui\Form\EntityDisplayFormBase
- class \Drupal\field_ui\Form\EntityDisplayFormBase extends \Drupal\Core\Entity\EntityForm
- class \Drupal\Core\Entity\EntityForm implements \Drupal\Core\Entity\EntityFormInterface extends \Drupal\Core\Form\FormBase
Expanded class hierarchy of EntityViewDisplayEditForm
3 files declare their use of EntityViewDisplayEditForm
- EntityDisplayFormBaseTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityDisplayFormBaseTest.php - FieldLayoutEntityViewDisplayEditForm.php in core/
modules/ field_layout/ src/ Form/ FieldLayoutEntityViewDisplayEditForm.php - LayoutBuilderEntityViewDisplayForm.php in core/
modules/ layout_builder/ src/ Form/ LayoutBuilderEntityViewDisplayForm.php
File
-
core/
modules/ field_ui/ src/ Form/ EntityViewDisplayEditForm.php, line 17
Namespace
Drupal\field_ui\FormView source
class EntityViewDisplayEditForm extends EntityDisplayFormBase {
/**
* {@inheritdoc}
*/
protected $displayContext = 'view';
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('plugin.manager.field.field_type'), $container->get('plugin.manager.field.formatter'), $container->get('entity_display.repository'), $container->get('entity_field.manager'));
}
/**
* {@inheritdoc}
*/
protected function buildFieldRow(FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
$field_row = parent::buildFieldRow($field_definition, $form, $form_state);
$field_name = $field_definition->getName();
$display_options = $this->entity
->getComponent($field_name);
// Insert the label column.
$label = [
'label' => [
'#type' => 'select',
'#title' => $this->t('Label display for @title', [
'@title' => $field_definition->getLabel(),
]),
'#title_display' => 'invisible',
'#options' => $this->getFieldLabelOptions(),
'#default_value' => $display_options ? $display_options['label'] : 'above',
],
];
$label_position = array_search('plugin', array_keys($field_row));
$field_row = array_slice($field_row, 0, $label_position, TRUE) + $label + array_slice($field_row, $label_position, count($field_row) - 1, TRUE);
// Update the (invisible) title of the 'plugin' column.
$field_row['plugin']['#title'] = $this->t('Formatter for @title', [
'@title' => $field_definition->getLabel(),
]);
if (!empty($field_row['plugin']['settings_edit_form']) && $plugin = $this->entity
->getRenderer($field_name)) {
$plugin_type_info = $plugin->getPluginDefinition();
$field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Format settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>';
}
return $field_row;
}
/**
* {@inheritdoc}
*/
protected function buildExtraFieldRow($field_id, $extra_field) {
$extra_field_row = parent::buildExtraFieldRow($field_id, $extra_field);
// Insert an empty placeholder for the label column.
$label = [
'empty_cell' => [
'#markup' => ' ',
],
];
$label_position = array_search('plugin', array_keys($extra_field_row));
$extra_field_row = array_slice($extra_field_row, 0, $label_position, TRUE) + $label + array_slice($extra_field_row, $label_position, count($extra_field_row) - 1, TRUE);
return $extra_field_row;
}
/**
* {@inheritdoc}
*/
protected function getEntityDisplay($entity_type_id, $bundle, $mode) {
return $this->entityDisplayRepository
->getViewDisplay($entity_type_id, $bundle, $mode);
}
/**
* {@inheritdoc}
*/
protected function getDefaultPlugin($field_type) {
return isset($this->fieldTypes[$field_type]['default_formatter']) ? $this->fieldTypes[$field_type]['default_formatter'] : NULL;
}
/**
* {@inheritdoc}
*/
protected function getDisplayModes() {
return $this->entityDisplayRepository
->getViewModes($this->entity
->getTargetEntityTypeId());
}
/**
* {@inheritdoc}
*/
protected function getDisplayModeOptions() {
return $this->entityDisplayRepository
->getViewModeOptions($this->entity
->getTargetEntityTypeId());
}
/**
* {@inheritdoc}
*/
protected function getDisplayModesLink() {
return [
'#type' => 'link',
'#title' => t('Manage view modes'),
'#url' => Url::fromRoute('entity.entity_view_mode.collection'),
];
}
/**
* {@inheritdoc}
*/
protected function getTableHeader() {
return [
$this->t('Field'),
$this->t('Weight'),
$this->t('Parent'),
$this->t('Region'),
$this->t('Label'),
[
'data' => $this->t('Format'),
'colspan' => 3,
],
];
}
/**
* {@inheritdoc}
*/
protected function getOverviewUrl($mode) {
$entity_type = $this->entityTypeManager
->getDefinition($this->entity
->getTargetEntityTypeId());
return Url::fromRoute('entity.entity_view_display.' . $this->entity
->getTargetEntityTypeId() . '.view_mode', [
'view_mode_name' => $mode,
] + FieldUI::getRouteBundleParameter($entity_type, $this->entity
->getTargetBundle()));
}
/**
* Returns an array of visibility options for field labels.
*
* @return array
* An array of visibility options.
*/
protected function getFieldLabelOptions() {
return [
'above' => $this->t('Above'),
'inline' => $this->t('Inline'),
'hidden' => '- ' . $this->t('Hidden') . ' -',
'visually_hidden' => '- ' . $this->t('Visually Hidden') . ' -',
];
}
/**
* {@inheritdoc}
*/
protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
$settings_form = [];
// Invoke hook_field_formatter_third_party_settings_form(), keying resulting
// subforms by module name.
foreach ($this->moduleHandler
->getImplementations('field_formatter_third_party_settings_form') as $module) {
$settings_form[$module] = $this->moduleHandler
->invoke($module, 'field_formatter_third_party_settings_form', [
$plugin,
$field_definition,
$this->entity
->getMode(),
$form,
$form_state,
]);
}
return $settings_form;
}
/**
* {@inheritdoc}
*/
protected function alterSettingsSummary(array &$summary, PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition) {
$context = [
'formatter' => $plugin,
'field_definition' => $field_definition,
'view_mode' => $this->entity
->getMode(),
];
$this->moduleHandler
->alter('field_formatter_settings_summary', $summary, $context);
}
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
|---|---|---|---|---|---|---|
| DependencySerializationTrait::$_entityStorages | protected | property | An array of entity type IDs keyed by the property name of their storages. | |||
| DependencySerializationTrait::$_serviceIds | protected | property | An array of service IDs keyed by property name used for serialization. | |||
| DependencySerializationTrait::__sleep | public | function | 1 | |||
| DependencySerializationTrait::__wakeup | public | function | 2 | |||
| EntityDisplayFormBase::$entity | protected | property | The entity being used by this form. | Overrides EntityForm::$entity | 1 | |
| EntityDisplayFormBase::$entityDisplayRepository | protected | property | The entity display repository. | |||
| EntityDisplayFormBase::$entityFieldManager | protected | property | The entity field manager. | |||
| EntityDisplayFormBase::$fieldTypes | protected | property | A list of field types. | |||
| EntityDisplayFormBase::$pluginManager | protected | property | The widget or formatter plugin manager. | |||
| EntityDisplayFormBase::copyFormValuesToEntity | protected | function | Overrides EntityForm::copyFormValuesToEntity | 1 | ||
| EntityDisplayFormBase::form | public | function | Overrides EntityForm::form | 1 | ||
| EntityDisplayFormBase::getApplicablePluginOptions | protected | function | Returns an array of applicable widget or formatter options for a field. | |||
| EntityDisplayFormBase::getDisplays | protected | function | Returns entity (form) displays for the current entity display type. | |||
| EntityDisplayFormBase::getDisplayStatuses | protected | function | Returns form or view modes statuses for the bundle used by this form. | |||
| EntityDisplayFormBase::getEntityFromRouteMatch | public | function | Overrides EntityForm::getEntityFromRouteMatch | |||
| EntityDisplayFormBase::getExtraFields | protected | function | Returns the extra fields of the entity type and bundle used by this form. | |||
| EntityDisplayFormBase::getFieldDefinitions | protected | function | Collects the definitions of fields whose display is configurable. | |||
| EntityDisplayFormBase::getRegionOptions | public | function | Returns an associative array of all regions. | |||
| EntityDisplayFormBase::getRegions | public | function | Get the regions needed to create the overview form. | |||
| EntityDisplayFormBase::getRowRegion | public | function | Returns the region to which a row in the display overview belongs. | |||
| EntityDisplayFormBase::multistepAjax | public | function | Ajax handler for multistep buttons. | |||
| EntityDisplayFormBase::multistepSubmit | public | function | Form submission handler for multistep buttons. | |||
| EntityDisplayFormBase::reduceOrder | Deprecated | public | function | Determines the rendering order of an array representing a tree. | ||
| EntityDisplayFormBase::saveDisplayStatuses | protected | function | Saves the updated display mode statuses. | |||
| EntityDisplayFormBase::submitForm | public | function | Overrides EntityForm::submitForm | |||
| EntityDisplayFormBase::tablePreRender | Deprecated | public | function | Performs pre-render tasks on field_ui_table elements. | ||
| EntityDisplayFormBase::__construct | public | function | Constructs a new EntityDisplayFormBase. | 2 | ||
| EntityForm::$entityTypeManager | protected | property | The entity type manager. | 3 | ||
| EntityForm::$moduleHandler | protected | property | The module handler service. | |||
| EntityForm::$operation | protected | property | The name of the current operation. | |||
| EntityForm::$privateEntityManager | private | property | The entity manager. | |||
| EntityForm::actions | protected | function | Returns an array of supported actions for the current entity form. | 36 | ||
| EntityForm::actionsElement | protected | function | Returns the action form element for the current entity form. | |||
| EntityForm::afterBuild | public | function | Form element #after_build callback: Updates the entity with submitted data. | |||
| EntityForm::buildEntity | public | function | Overrides EntityFormInterface::buildEntity | 3 | ||
| EntityForm::buildForm | public | function | Overrides FormInterface::buildForm | 13 | ||
| EntityForm::getBaseFormId | public | function | Overrides BaseFormIdInterface::getBaseFormId | 6 | ||
| EntityForm::getEntity | public | function | Overrides EntityFormInterface::getEntity | |||
| EntityForm::getFormId | public | function | Overrides FormInterface::getFormId | 12 | ||
| EntityForm::getOperation | public | function | Overrides EntityFormInterface::getOperation | |||
| EntityForm::init | protected | function | Initialize the form state and the entity before the first form build. | 3 | ||
| EntityForm::prepareEntity | protected | function | Prepares the entity object before the form is built first. | 3 | ||
| EntityForm::prepareInvokeAll | protected | function | Invokes the specified prepare hook variant. | |||
| EntityForm::processForm | public | function | Process callback: assigns weights and hides extra fields. | |||
| EntityForm::save | public | function | Overrides EntityFormInterface::save | 47 | ||
| EntityForm::setEntity | public | function | Overrides EntityFormInterface::setEntity | |||
| EntityForm::setEntityManager | public | function | Overrides EntityFormInterface::setEntityManager | |||
| EntityForm::setEntityTypeManager | public | function | Overrides EntityFormInterface::setEntityTypeManager | |||
| EntityForm::setModuleHandler | public | function | Overrides EntityFormInterface::setModuleHandler | |||
| EntityForm::setOperation | public | function | Overrides EntityFormInterface::setOperation | |||
| EntityForm::__get | public | function | ||||
| EntityForm::__set | public | function | ||||
| EntityViewDisplayEditForm::$displayContext | protected | property | Overrides EntityDisplayFormBase::$displayContext | |||
| EntityViewDisplayEditForm::alterSettingsSummary | protected | function | Overrides EntityDisplayFormBase::alterSettingsSummary | |||
| EntityViewDisplayEditForm::buildExtraFieldRow | protected | function | Overrides EntityDisplayFormBase::buildExtraFieldRow | 1 | ||
| EntityViewDisplayEditForm::buildFieldRow | protected | function | Overrides EntityDisplayFormBase::buildFieldRow | 1 | ||
| EntityViewDisplayEditForm::create | public static | function | Overrides FormBase::create | 1 | ||
| EntityViewDisplayEditForm::getDefaultPlugin | protected | function | Overrides EntityDisplayFormBase::getDefaultPlugin | |||
| EntityViewDisplayEditForm::getDisplayModeOptions | protected | function | Overrides EntityDisplayFormBase::getDisplayModeOptions | |||
| EntityViewDisplayEditForm::getDisplayModes | protected | function | Overrides EntityDisplayFormBase::getDisplayModes | |||
| EntityViewDisplayEditForm::getDisplayModesLink | protected | function | Overrides EntityDisplayFormBase::getDisplayModesLink | |||
| EntityViewDisplayEditForm::getEntityDisplay | protected | function | Overrides EntityDisplayFormBase::getEntityDisplay | |||
| EntityViewDisplayEditForm::getFieldLabelOptions | protected | function | Returns an array of visibility options for field labels. | |||
| EntityViewDisplayEditForm::getOverviewUrl | protected | function | Overrides EntityDisplayFormBase::getOverviewUrl | |||
| EntityViewDisplayEditForm::getTableHeader | protected | function | Overrides EntityDisplayFormBase::getTableHeader | |||
| EntityViewDisplayEditForm::thirdPartySettingsForm | protected | function | Overrides EntityDisplayFormBase::thirdPartySettingsForm | |||
| FormBase::$configFactory | protected | property | The config factory. | 3 | ||
| FormBase::$requestStack | protected | property | The request stack. | 1 | ||
| FormBase::$routeMatch | protected | property | The route match. | |||
| FormBase::config | protected | function | Retrieves a configuration object. | |||
| FormBase::configFactory | protected | function | Gets the config factory for this form. | 3 | ||
| FormBase::container | private | function | Returns the service container. | |||
| FormBase::currentUser | protected | function | Gets the current user. | |||
| FormBase::getRequest | protected | function | Gets the request object. | |||
| FormBase::getRouteMatch | protected | function | Gets the route match. | |||
| FormBase::logger | protected | function | Gets the logger for a specific channel. | |||
| FormBase::redirect | protected | function | Returns a redirect response object for the specified route. | Overrides UrlGeneratorTrait::redirect | ||
| FormBase::resetConfigFactory | public | function | Resets the configuration factory. | |||
| FormBase::setConfigFactory | public | function | Sets the config factory for this form. | |||
| FormBase::setRequestStack | public | function | Sets the request stack object to use. | |||
| FormBase::validateForm | public | function | Overrides FormInterface::validateForm | 73 | ||
| LinkGeneratorTrait::$linkGenerator | protected | property | The link generator. | 1 | ||
| LinkGeneratorTrait::getLinkGenerator | Deprecated | protected | function | Returns the link generator. | ||
| LinkGeneratorTrait::l | Deprecated | protected | function | Renders a link to a route given a route name and its parameters. | ||
| LinkGeneratorTrait::setLinkGenerator | Deprecated | public | function | Sets the link generator service. | ||
| LoggerChannelTrait::$loggerFactory | protected | property | The logger channel factory service. | |||
| LoggerChannelTrait::getLogger | protected | function | Gets the logger for a specific channel. | |||
| LoggerChannelTrait::setLoggerFactory | public | function | Injects the logger channel factory. | |||
| MessengerTrait::$messenger | protected | property | The messenger. | 29 | ||
| MessengerTrait::messenger | public | function | Gets the messenger. | 29 | ||
| MessengerTrait::setMessenger | public | function | Sets the messenger. | |||
| RedirectDestinationTrait::$redirectDestination | protected | property | The redirect destination service. | 1 | ||
| RedirectDestinationTrait::getDestinationArray | protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |||
| RedirectDestinationTrait::getRedirectDestination | protected | function | Returns the redirect destination service. | |||
| RedirectDestinationTrait::setRedirectDestination | public | function | Sets the redirect destination service. | |||
| StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 1 | ||
| StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | |||
| StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | |||
| StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | |||
| StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | ||
| StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | |||
| UrlGeneratorTrait::$urlGenerator | protected | property | The url generator. | |||
| UrlGeneratorTrait::getUrlGenerator | Deprecated | protected | function | Returns the URL generator service. | ||
| UrlGeneratorTrait::setUrlGenerator | Deprecated | public | function | Sets the URL generator service. | ||
| UrlGeneratorTrait::url | Deprecated | protected | function | Generates a URL or path for a specific route based on the given parameters. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.