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.
17 class EntityFormDisplayEditForm extends EntityDisplayFormBase {
22 protected $displayContext = 'form';
27 public static function create(ContainerInterface $container) {
29 $container->get('plugin.manager.field.field_type'),
30 $container->get('plugin.manager.field.widget')
37 protected function buildFieldRow(FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
38 $field_row = parent::buildFieldRow($field_definition, $form, $form_state);
40 $field_name = $field_definition->getName();
42 // Update the (invisible) title of the 'plugin' column.
43 $field_row['plugin']['#title'] = $this->t('Formatter for @title', ['@title' => $field_definition->getLabel()]);
44 if (!empty($field_row['plugin']['settings_edit_form']) && ($plugin = $this->entity->getRenderer($field_name))) {
45 $plugin_type_info = $plugin->getPluginDefinition();
46 $field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Widget settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>';
55 protected function getEntityDisplay($entity_type_id, $bundle, $mode) {
56 return entity_get_form_display($entity_type_id, $bundle, $mode);
62 protected function getDefaultPlugin($field_type) {
63 return isset($this->fieldTypes[$field_type]['default_widget']) ? $this->fieldTypes[$field_type]['default_widget'] : NULL;
69 protected function getDisplayModes() {
70 return $this->entityManager->getFormModes($this->entity->getTargetEntityTypeId());
76 protected function getDisplayModeOptions() {
77 return $this->entityManager->getFormModeOptions($this->entity->getTargetEntityTypeId());
83 protected function getDisplayModesLink() {
86 '#title' => t('Manage form modes'),
87 '#url' => Url::fromRoute('entity.entity_form_mode.collection'),
94 protected function getTableHeader() {
100 ['data' => $this->t('Widget'), 'colspan' => 3],
107 protected function getOverviewUrl($mode) {
108 $entity_type = $this->entityManager->getDefinition($this->entity->getTargetEntityTypeId());
109 return Url::fromRoute('entity.entity_form_display.' . $this->entity->getTargetEntityTypeId() . '.form_mode', [
110 'form_mode_name' => $mode,
111 ] + FieldUI::getRouteBundleParameter($entity_type, $this->entity->getTargetBundle()));
117 protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
119 // Invoke hook_field_widget_third_party_settings_form(), keying resulting
120 // subforms by module name.
121 foreach ($this->moduleHandler->getImplementations('field_widget_third_party_settings_form') as $module) {
122 $settings_form[$module] = $this->moduleHandler->invoke($module, 'field_widget_third_party_settings_form', [
125 $this->entity->getMode(),
130 return $settings_form;
136 protected function alterSettingsSummary(array &$summary, PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition) {
139 'field_definition' => $field_definition,
140 'form_mode' => $this->entity->getMode(),
142 $this->moduleHandler->alter('field_widget_settings_summary', $summary, $context);