You are here

public function CpfWithMaskWidget::settingsSummary in CPF 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/CpfWithMaskWidget.php \Drupal\cpf\Plugin\Field\FieldWidget\CpfWithMaskWidget::settingsSummary()

Returns a short summary for the current widget settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Return value

array A short summary of the widget settings.

Overrides WidgetBase::settingsSummary

File

src/Plugin/Field/FieldWidget/CpfWithMaskWidget.php, line 68

Class

CpfWithMaskWidget
Plugin implementation of the 'cpf_with_mask' widget.

Namespace

Drupal\cpf\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  $summary[] = $this
    ->t('Textfield size: @size', [
    '@size' => $this
      ->getSetting('size'),
  ]);
  $placeholder = $this
    ->getSetting('placeholder');
  if (!empty($placeholder)) {
    $summary[] = $this
      ->t('Placeholder: @placeholder', [
      '@placeholder' => $placeholder,
    ]);
  }
  $mask = $this
    ->getSetting('mask');
  if (!empty($mask)) {
    $summary[] = $this
      ->t('Mask: @mask', [
      '@mask' => $mask,
    ]);
  }
  $generator = empty($this
    ->getSetting('generator')) ? $this
    ->t('no') : $this
    ->t('yes');
  $summary[] = $this
    ->t('Link to generate CPF numbers: @generator', [
    '@generator' => $generator,
  ]);
  return $summary;
}