public static function Number::preRenderNumber in Price 3.0.x
Same name and namespace in other branches
- 8 src/Element/Number.php \Drupal\price\Element\Number::preRenderNumber()
- 3.x src/Element/Number.php \Drupal\price\Element\Number::preRenderNumber()
- 2.0.x src/Element/Number.php \Drupal\price\Element\Number::preRenderNumber()
- 2.x src/Element/Number.php \Drupal\price\Element\Number::preRenderNumber()
Prepares a #type 'price_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 170
Class
- Number
- Provides a number form element with support for language-specific input.
Namespace
Drupal\price\ElementCode
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;
}