You are here

public static function Number::preRenderNumber in Commerce Core 8.2

Prepares a #type 'commerce_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

modules/price/src/Element/Number.php, line 166

Class

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

Namespace

Drupal\commerce_price\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;
}