3 namespace Drupal\Core\Render\Element;
5 use Drupal\Core\Render\Element;
8 * Provides a form element for entering a telephone number.
10 * Provides an HTML5 input element with type of "tel". It provides no special
14 * - #size: The size of the input element in characters.
18 * $form['phone'] = array(
20 * '#title' => $this->t('Phone'),
24 * @see \Drupal\Core\Render\Element
28 class Tel extends FormElement {
33 public function getInfo() {
34 $class = get_class($this);
39 '#autocomplete_route_name' => FALSE,
41 [$class, 'processAutocomplete'],
42 [$class, 'processAjaxForm'],
43 [$class, 'processPattern'],
46 [$class, 'preRenderTel'],
48 '#theme' => 'input__tel',
49 '#theme_wrappers' => ['form_element'],
54 * Prepares a #type 'tel' render element for input.html.twig.
56 * @param array $element
57 * An associative array containing the properties of the element.
58 * Properties used: #title, #value, #description, #size, #maxlength,
59 * #placeholder, #required, #attributes.
62 * The $element with prepared variables ready for input.html.twig.
64 public static function preRenderTel($element) {
65 $element['#attributes']['type'] = 'tel';
66 Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']);
67 static::setAttributes($element, ['form-tel']);