3 namespace Drupal\field_ui\Form;
5 use Drupal\Core\Field\FieldDefinitionInterface;
6 use Drupal\Core\Field\PluginSettingsInterface;
7 use Drupal\Core\Form\FormStateInterface;
9 use Drupal\field_ui\FieldUI;
10 use Symfony\Component\DependencyInjection\ContainerInterface;
13 * Edit form for the EntityFormDisplay entity type.
15 class EntityFormDisplayEditForm extends EntityDisplayFormBase {
20 protected $displayContext = 'form';
25 public static function create(ContainerInterface $container) {
27 $container->get('plugin.manager.field.field_type'),
28 $container->get('plugin.manager.field.widget')
35 protected function buildFieldRow(FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
36 $field_row = parent::buildFieldRow($field_definition, $form, $form_state);
38 $field_name = $field_definition->getName();
40 // Update the (invisible) title of the 'plugin' column.
41 $field_row['plugin']['#title'] = $this->t('Formatter for @title', ['@title' => $field_definition->getLabel()]);
42 if (!empty($field_row['plugin']['settings_edit_form']) && ($plugin = $this->entity->getRenderer($field_name))) {
43 $plugin_type_info = $plugin->getPluginDefinition();
44 $field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Widget settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>';
53 protected function getEntityDisplay($entity_type_id, $bundle, $mode) {
54 return entity_get_form_display($entity_type_id, $bundle, $mode);
60 protected function getDefaultPlugin($field_type) {
61 return isset($this->fieldTypes[$field_type]['default_widget']) ? $this->fieldTypes[$field_type]['default_widget'] : NULL;
67 protected function getDisplayModes() {
68 return $this->entityManager->getFormModes($this->entity->getTargetEntityTypeId());
74 protected function getDisplayModeOptions() {
75 return $this->entityManager->getFormModeOptions($this->entity->getTargetEntityTypeId());
81 protected function getDisplayModesLink() {
84 '#title' => t('Manage form modes'),
85 '#url' => Url::fromRoute('entity.entity_form_mode.collection'),
92 protected function getTableHeader() {
98 ['data' => $this->t('Widget'), 'colspan' => 3],
105 protected function getOverviewUrl($mode) {
106 $entity_type = $this->entityManager->getDefinition($this->entity->getTargetEntityTypeId());
107 return Url::fromRoute('entity.entity_form_display.' . $this->entity->getTargetEntityTypeId() . '.form_mode', [
108 'form_mode_name' => $mode,
109 ] + FieldUI::getRouteBundleParameter($entity_type, $this->entity->getTargetBundle()));
115 protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
117 // Invoke hook_field_widget_third_party_settings_form(), keying resulting
118 // subforms by module name.
119 foreach ($this->moduleHandler->getImplementations('field_widget_third_party_settings_form') as $module) {
120 $settings_form[$module] = $this->moduleHandler->invoke($module, 'field_widget_third_party_settings_form', [
123 $this->entity->getMode(),
128 return $settings_form;
134 protected function alterSettingsSummary(array &$summary, PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition) {
137 'field_definition' => $field_definition,
138 'form_mode' => $this->entity->getMode(),
140 $this->moduleHandler->alter('field_widget_settings_summary', $summary, $context);