Skip to content

Commit afda1c3

Browse files
committed
Fix required checkbox rendering so label gets proper styles, add hook_preprocess_form_element to set required market for twig
1 parent 9a0838e commit afda1c3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

templates/input/form-element.html.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
is_radio ? 'radio',
6262
is_checkbox ? 'checkbox',
6363
is_autocomplete ? 'form-autocomplete',
64-
has_error ? 'error has-error'
64+
has_error ? 'error has-error',
65+
required ? 'required',
6566
]
6667
%}{%
6768
set description_classes = [

wxt_bootstrap.theme

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,12 @@ function wxt_bootstrap_preprocess_paragraph(&$variables) {
338338
$variables['link_provider_label'] = $allowed_values[$key] ?? $key;
339339
}
340340
}
341+
342+
/**
343+
* Implements hook_preprocess_form_element().
344+
*/
345+
function wxt_bootstrap_preprocess_form_element(array &$variables) {
346+
if (!empty($variables['element']['#required'])) {
347+
$variables['required'] = TRUE;
348+
}
349+
}

0 commit comments

Comments
 (0)