Textfield.php 866 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
use Drupal\Core\TypedData\DataDefinitionInterface;
13 14 15 16

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

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

}