public static function WebformSignature::preRenderWebformSignature in Webform 8.5
Same name and namespace in other branches
- 6.x src/Element/WebformSignature.php \Drupal\webform\Element\WebformSignature::preRenderWebformSignature()
Prepares a #type 'webform_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/ WebformSignature.php, line 64
Class
- WebformSignature
- Provides a webform element for entering a signature.
Namespace
Drupal\webform\ElementCode
public static function preRenderWebformSignature(array $element) {
$element['#attributes']['type'] = 'hidden';
Element::setAttributes($element, [
'name',
'value',
]);
static::setAttributes($element, [
'js-webform-signature',
'form-webform-signature',
]);
$build = [
'#prefix' => '<div class="js-webform-signature-pad webform-signature-pad">',
'#suffix' => '</div>',
];
$build['reset'] = [
'#type' => 'button',
'#value' => t('Reset'),
];
$build['canvas'] = [
'#type' => 'html_tag',
'#tag' => 'canvas',
];
$element['#children'] = $build;
$element['#attached']['library'][] = 'webform/webform.element.signature';
return $element;
}