Issue #2671446 by heykarthikwithu, mikeker: The Boolean field formatter does not provide a settings summary

8.1.x
Nathaniel Catchpole 2016-02-29 15:32:23 +09:00
parent 2c88729acf
commit 89eadd7286
2 changed files with 30 additions and 0 deletions

View File

@ -114,6 +114,30 @@ class BooleanFormatter extends FormatterBase {
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}
*/

View File

@ -125,6 +125,12 @@ class BooleanFormatterSettingsTest extends WebTestBase {
}
$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.");
}
}
}