You are here

protected function DateTimeTimeAgoListFormatter::postProcessSettingsForm in Formatter Suite 8

Post-processes the settings form after it has been built.

Parameters

array $elements: The form's elements.

Overrides EntityListTrait::postProcessSettingsForm

File

src/Plugin/Field/FieldFormatter/DateTimeTimeAgoListFormatter.php, line 47

Class

DateTimeTimeAgoListFormatter
Formats multiple time ago date strings as a list.

Namespace

Drupal\formatter_suite\Plugin\Field\FieldFormatter

Code

protected function postProcessSettingsForm(array $elements) {

  // The Drupal core DateTimeTimeAgoFormatter creates textfields for the time
  // formats, but doesn't set the textfield's size. This makes it hard to lay
  // it out in the formatter's UI. So, give it a small size. CSS then widens
  // it to the width of the UI.
  if (isset($elements['future_format']) === TRUE) {
    $elements['future_format']['#size'] = 10;
    $elements['future_format']['#attributes']['size'] = 10;
    $elements['future_format']['#attributes']['spellcheck'] = FALSE;
    $elements['future_format']['#attributes']['autocomplete'] = 'off';
    $elements['future_format']['#attributes']['autocapitalize'] = 'none';
    $elements['future_format']['#attributes']['autocorrect'] = 'off';
  }
  if (isset($elements['past_format']) === TRUE) {
    $elements['past_format']['#size'] = 10;
    $elements['past_format']['#attributes']['size'] = 10;
    $elements['past_format']['#attributes']['spellcheck'] = FALSE;
    $elements['past_format']['#attributes']['autocomplete'] = 'off';
    $elements['past_format']['#attributes']['autocapitalize'] = 'none';
    $elements['past_format']['#attributes']['autocorrect'] = 'off';
  }
  return $elements;
}