You are here

public function TextFieldCounterWidgetTrait::addMaxlengthSummary in Textfield Counter 8

Adds the summary of the maximum number of allowed characters.

Parameters

array $summary: The array of summaries to which the summary should be added.

5 calls to TextFieldCounterWidgetTrait::addMaxlengthSummary()
StringTextareaWithCounterWidget::settingsSummary in src/Plugin/Field/FieldWidget/StringTextareaWithCounterWidget.php
Returns a short summary for the current widget settings.
StringTextfieldWithCounterWidget::settingsSummary in src/Plugin/Field/FieldWidget/StringTextfieldWithCounterWidget.php
Returns a short summary for the current widget settings.
TextareaWithCounterWidget::settingsSummary in src/Plugin/Field/FieldWidget/TextareaWithCounterWidget.php
Returns a short summary for the current widget settings.
TextareaWithSummaryAndCounterWidget::settingsSummary in src/Plugin/Field/FieldWidget/TextareaWithSummaryAndCounterWidget.php
Returns a short summary for the current widget settings.
TextfieldWithCounterWidget::settingsSummary in src/Plugin/Field/FieldWidget/TextfieldWithCounterWidget.php
Returns a short summary for the current widget settings.

File

src/Plugin/Field/FieldWidget/TextFieldCounterWidgetTrait.php, line 218

Class

TextFieldCounterWidgetTrait
Textfield counter trait. Adds textfield counting functionality.

Namespace

Drupal\textfield_counter\Plugin\Field\FieldWidget

Code

public function addMaxlengthSummary(array &$summary) {
  if ($this
    ->getSetting('use_field_maxlength')) {
    $text = $this
      ->t('Maximum number of characters: %count (field default)', [
      '%count' => $this
        ->getFieldSetting('max_length'),
    ]);
  }
  else {
    $maxlength = $this
      ->getSetting('maxlength');
    $text = $this
      ->t('Maximum number of characters: %count', [
      '%count' => $maxlength ? $maxlength : $this
        ->t('Disabled'),
    ]);
  }
  $summary['maxlength'] = $text;
}