You are here

protected static function ScssNumber::processUnitSingle in SCSS Compiler 1.0.x

Add a hidden unit input to the composite form element.

Parameters

array $element: The element to which a hidden unit input should be added.

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

array $complete_form: The complete form.

Return value

array The resulting element after having been processed.

1 call to ScssNumber::processUnitSingle()
ScssNumber::processNumber in src/Element/ScssNumber.php
Process the element before it gets rendered in the form.

File

src/Element/ScssNumber.php, line 492

Class

ScssNumber
A form element to represent Sass numbers with a unit.

Namespace

Drupal\compiler_scss\Element

Code

protected static function processUnitSingle(array &$element, FormStateInterface $form_state, array &$complete_form) {

  // Store the only possible unit in a hidden input on the form.
  $element['unit'] = [
    '#type' => 'hidden',
    '#name' => "{$element['#name']}[unit]",
    '#value' => key($element['#unit_options']),
  ];
  return $element;
}