Clientside validation breaks checkbox toggle

Created on 12 April 2024, 7 months ago
Updated 29 May 2024, 6 months ago

Problem/Motivation

After enabling the clientside_validation and clientside_validation_jquery modules, all checkboxes in the administrative area are not visible.

Proposed resolution

It seems like the issue is this this line, since $variables['element']['#error_no_message'] is being set on all fields after enabling clientside_validation.

function gin_theme_suggestions_input_alter(array &$suggestions, array $variables) {
  if ($variables['element']['#type'] === 'checkbox') {
    // Way to identify if checkbox is in a checkboxes group
    // as Drupal doesn't provide one yet (see #2643012)
    if (!isset($variables['element']['#error_no_message'])) {
      $suggestions[] = 'input__checkbox__toggle';
    }
  }
}

As proposed here https://www.drupal.org/project/drupal/issues/2643012 I tried changing validation to !is_float($variables['element']['#weight']) but got inconsistent results.

Removing this check entirely seems to be fixing the problem and checkboxes groups are not affected even if using the input__checkbox__toggle template as different style is applied in CSS.

Before doing any changes I want to confirm that removing the isset($variables['element']['#error_no_message']) will not have any negative impact. Added a temporary patch.

PS: Similar issue reported here https://www.drupal.org/project/gin/issues/3276250 🐛 Gin theme checkbox styles breaks Webform custom composite fields required Closed: cannot reproduce

🐛 Bug report
Status

Fixed

Component

Code

Created by

🇷🇴Romania alexandru.dumitru Cluj

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024