You are here

public static function Number::preRenderNumber in Physical Fields 8

Prepares a #type 'physical_number' render element for input.html.twig.

Parameters

array $element: An associative array containing the properties of the element. Properties used: #title, #value, #description, #size, #maxlength, #placeholder, #required, #attributes.

Return value

array The $element with prepared variables ready for input.html.twig.

File

src/Element/Number.php, line 157

Class

Number
Provides a number form element with support for language-specific input.

Namespace

Drupal\physical\Element

Code

public static function preRenderNumber(array $element) {

  // We're not using the "number" type because it won't accept
  // language-specific input, such as commas.
  $element['#attributes']['type'] = 'text';
  Element::setAttributes($element, [
    'id',
    'name',
    'value',
    'size',
    'maxlength',
    'placeholder',
  ]);
  static::setAttributes($element, [
    'form-text',
  ]);
  return $element;
}