diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php index 74c7523f17270ef9233c222fab8e4788e458d44a..be7b94a5f8b25364a284328b7388cdaf4244cb25 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php @@ -114,6 +114,30 @@ public function settingsForm(array $form, FormStateInterface $form_state) { return $form; } + /** + * {@inheritdoc} + */ + public function settingsSummary() { + $summary = []; + $setting = $this->getSetting('format'); + + if ($setting == 'custom') { + $summary[] = $this->t('Custom text: @true_label / @false_label', [ + '@true_label' => $this->getSetting('format_custom_true'), + '@false_label' => $this->getSetting('format_custom_false'), + ]); + } + else { + $formats = $this->getOutputFormats(); + $summary[] = $this->t('Display: @true_label / @false_label', [ + '@true_label' => $formats[$setting][0], + '@false_label' => $formats[$setting][1], + ]); + } + + return $summary; + } + /** * {@inheritdoc} */ diff --git a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php index 8c5146b49e35709b51ae235ef573061a3a6686a4..ce2ba074268376ffa867156e708c08534ced3c74 100644 --- a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php @@ -125,6 +125,12 @@ function testBooleanFormatterSettings() { } $this->assertText(SafeMarkup::format($default, array('@on' => $values[0], '@off' => $values[1]))); } + + foreach ($settings as $values) { + $this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/display'); + $result = $this->xpath('//div[contains(@class, :class) and contains(text(), :text)]', [':class' => 'field-plugin-summary', ':text' => 'Display: TRUE / FALSE']); + $this->assertEqual(count($result), 1, "Boolean formatter settings summary exist."); + } } }