public function KeyValueWidgetTrait::settingsSummary in Key value field 8
File
- src/
Plugin/ Field/ FieldWidget/ KeyValueWidgetTrait.php, line 126
Class
- KeyValueWidgetTrait
- Common traits for key value field widgets inheriting from different widgets.
Namespace
Drupal\key_value_field\Plugin\Field\FieldWidgetCode
public function settingsSummary() {
$summary = [];
// Add a summary for the key field.
$summary[] = t('Key label: @label', [
'@label' => $this
->getSetting('key_label'),
]);
$summary[] = t('Value label: @label', [
'@label' => $this
->getSetting('value_label'),
]);
$summary[] = t('Key textfield size: @size', [
'@size' => $this
->getSetting('key_size'),
]);
if (($placeholder = $this
->getSetting('key_placeholder')) && !empty($placeholder)) {
$summary[] = t('Key Placeholder: "@placeholder"', [
'@placeholder' => $placeholder,
]);
}
// Add a summary for the value placeholder.
if (($placeholder = $this
->getSetting('placeholder')) && !empty($placeholder)) {
$summary[] = t('Value Placeholder: "@placeholder"', [
'@placeholder' => $placeholder,
]);
}
// Add a summary for the description if it is enabled.
if ($this
->getSetting('description_enabled') && ($placeholder = $this
->getSetting('description_placeholder')) && !empty($placeholder)) {
$summary[] = t('Description: Enabled', [
'@placeholder' => $placeholder,
]);
$summary[] = t('- Placeholder: @placeholder', [
'@placeholder' => $placeholder,
]);
$summary[] = t('- Label: @label', [
'@label' => $this
->getSetting('description_label'),
]);
$summary[] = t('- Rows: @rows', [
'@rows' => $this
->getSetting('description_rows'),
]);
}
return $summary + parent::settingsSummary();
}