Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #3495607:Update preprocessing of checkboxes. #1319

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions web/themes/contrib/civictheme/includes/form_element.inc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function civictheme_preprocess_fieldset__form_element__civictheme_field__checkbo
'value' => $value,
'name' => $name . '[' . $value . ']',
'id' => Html::cleanCssIdentifier($element['#id'] . '-' . $value),
'is_checked' => is_array($element['#default_value']) ? in_array($value, $element['#default_value']) : $element['#default_value'] == $value,
'is_checked' => is_array($element['#value']) ? in_array($value, $element['#value']) : $element['#value'] == $value,
'is_disabled' => isset($element['#attributes']['disabled']),
// Checkboxes controls with a group cannot be required by definition.
'is_required' => FALSE,
Expand Down Expand Up @@ -295,7 +295,7 @@ function civictheme_preprocess_fieldset__form_element__civictheme_field__radios(
'value' => $value,
'name' => $name,
'id' => Html::cleanCssIdentifier($element['#id'] . '-' . $value),
'is_checked' => isset($element['#default_value']) ? (is_array($element['#default_value']) ? in_array($value, $element['#default_value']) : $element['#default_value'] == $value) : FALSE,
'is_checked' => isset($element['#value']) ? (is_array($element['#value']) ? in_array($value, $element['#value']) : $element['#value'] == $value) : FALSE,
'is_disabled' => isset($element['#attributes']['disabled']),
'attributes' => $attributes,
'modifier_class' => $modifier_class,
Expand Down Expand Up @@ -428,8 +428,9 @@ function _civictheme_preprocess_form_element__control(array &$variables): void {
'modifier_class' => $modifier_class,
];

if ($element['#type'] == 'checkbox') {
$variables['control'][0]['is_checked'] = $element['#default_value'] ?? FALSE;
if ($element['#type'] === 'checkbox') {
$variables['control'][0]['is_checked'] = $element['#value'] ?? FALSE;
$variables['control'][0]['is_checked'] = (bool) $variables['control'][0]['is_checked'];
}
}

Expand Down
Loading