You are here

public function Range::prepare in YAML Form 8

Prepare an element to be rendered within a form.

Parameters

array $element: An element.

\Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission: A form submission.

Overrides NumericBase::prepare

1 call to Range::prepare()
YamlFormRating::prepare in src/Plugin/YamlFormElement/YamlFormRating.php
Prepare an element to be rendered within a form.
1 method overrides Range::prepare()
YamlFormRating::prepare in src/Plugin/YamlFormElement/YamlFormRating.php
Prepare an element to be rendered within a form.

File

src/Plugin/YamlFormElement/Range.php, line 39

Class

Range
Provides a 'range' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
  parent::prepare($element, $yamlform_submission);
  if (!empty($element['#range__output'])) {
    $element['#attributes']['data-range-output'] = 'true';
    $element['#attributes']['class'][] = 'js-form-range-output';
    $element['#attributes']['class'][] = 'form-range-output';
    $element['#wrapper_attributes']['class'][] = 'js-form-type-range-output';
    $element['#wrapper_attributes']['class'][] = 'form-type-range-output';
    if (!empty($element['#range__output_prefix'])) {
      $element['#attributes']['data-range-output-prefix'] = $element['#range__output_prefix'];
    }
    if (!empty($element['#range__output_suffix'])) {
      $element['#attributes']['data-range-output-suffix'] = $element['#range__output_suffix'];
    }
    $element['#attached']['library'][] = 'yamlform/yamlform.element.range';
  }
}