Textfield.php 794 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Contains \Drupal\config_translation\FormElement\Textfield.
 */

namespace Drupal\config_translation\FormElement;

10
use Drupal\Core\Language\LanguageInterface;
11
use Drupal\Core\StringTranslation\StringTranslationTrait;
12 13 14 15

/**
 * Defines the textfield element for the configuration translation interface.
 */
16 17
class Textfield implements ElementInterface {
  use StringTranslationTrait;
18 19 20 21

  /**
   * {@inheritdoc}
   */
22
  public function getFormElement(array $definition, LanguageInterface $language, $value) {
23 24 25 26 27 28 29 30 31
    return array(
      '#type' => 'textfield',
      '#default_value' => $value,
      '#title' => $this->t($definition['label']) . '<span class="visually-hidden"> (' . $language->name . ')</span>',
      '#attributes' => array('lang' => $language->id),
    );
  }

}