Clientside validation breaks checkbox toggle

Created on 12 April 2024, 2 months ago
Updated 29 May 2024, 18 days 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

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

Comments & Activities

Production build 0.69.0 2024