-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjson_forms.module
More file actions
24 lines (20 loc) · 940 Bytes
/
json_forms.module
File metadata and controls
24 lines (20 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
declare(strict_types=1);
use Drupal\Core\Template\Attribute;
function _json_forms_add_tooltip_css_class(array &$variables): void {
if ('tooltip' === ($variables['element']['#_json_forms_description_display'] ?? NULL)) {
/** @var \Drupal\Core\Template\Attribute|null $descriptionAttributes */
$descriptionAttributes = $variables['description']['attributes'] ?? NULL;
if (NULL !== $descriptionAttributes) {
// Add the CSS class "json-forms-description-tooltip" to the description
// element. This can be used to process the element with another module.
$descriptionAttributes->merge(new Attribute(['class' => ['json-forms-description-tooltip']]));
}
}
}
function json_forms_preprocess_form_element(array &$variables): void {
_json_forms_add_tooltip_css_class($variables);
}
function json_forms_preprocess_fieldset(array &$variables): void {
_json_forms_add_tooltip_css_class($variables);
}