You are here

public static function YamlFormSignature::preRenderYamlFormSignature in YAML Form 8

Prepares a #type 'yamlform_signature' render element for input.html.twig.

Parameters

array $element: An associative array containing the properties of the element. Properties used: #title, #value, #description, #min, #max, #attributes, #step.

Return value

array The $element with prepared variables ready for input.html.twig.

File

src/Element/YamlFormSignature.php, line 45

Class

YamlFormSignature
Provides a form element for entering a signature.

Namespace

Drupal\yamlform\Element

Code

public static function preRenderYamlFormSignature($element) {
  $element['#attributes']['type'] = 'hidden';
  Element::setAttributes($element, [
    'name',
    'value',
  ]);
  static::setAttributes($element, [
    'js-yamlform-signature',
    'form-yamlform-signature',
  ]);
  $build = [
    '#prefix' => '<div class="js-yamlform-signature-pad yamlform-signature-pad">',
    '#suffix' => '</div>',
  ];
  $build['reset'] = [
    '#type' => 'button',
    '#value' => t('Reset'),
  ];
  $build['canvas'] = [
    '#type' => 'html_tag',
    '#tag' => 'canvas',
  ];
  $element['#children'] = $build;
  $element['#attached']['library'][] = 'yamlform/yamlform.element.signature';
  return $element;
}