You are here

public static function Number::processElement in Physical Fields 8

Builds the physical_number form element.

Parameters

array $element: The initial physical_number form element.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $complete_form: The complete form structure.

Return value

array The built physical_number form element.

File

src/Element/Number.php, line 94

Class

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

Namespace

Drupal\physical\Element

Code

public static function processElement(array $element, FormStateInterface $form_state, array &$complete_form) {

  // Provide an example to the end user so that they know which decimal
  // separator to use. This is the same pattern Drupal core uses.
  $number_formatter = \Drupal::service('physical.number_formatter');
  $element['#placeholder'] = $number_formatter
    ->format('9.99');
  return $element;
}