- 🇫🇷France goz
I have a similar issue, except I still don't understand why.
I don't use webform, it's a boolean field in a node, displayed byboolean_checkbox
form widget, withdisplay_label
option to 1.In my case, i can see debugging
gin_theme_suggestions_input_alter()
function that#error_no_message
exists and isTRUE
.Reading #2643012: Add property to identify if checkbox/radio is in group of checkboxes/radios → , checkboxes group is can be tested thanks to
#error_no_message
key AND#weight
. After few tests and reading\Drupal\Core\Render\Element\Checkboxes
, it seems checking#weight
is float is more relevant than#error_no_message
... but not the solution either.Here is an example of a form. I should have toggle checkbox for fields, but none is displayed :
- Publié (published status)
- My checkbox (a boolean field)
- Sidebar > Create new revision
- Sidebar > Menu settings > Provide a menu link
- Sidebar > Simple XML Sitemap > Regenerate all sitemaps after hitting Save
- Sidebar > URL alias > Generate automatic URL alias
Then checking
#weight
is not float to use template suggestion :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 (!is_float($variables['element']['#weight'])) { $suggestions[] = 'input__checkbox__toggle'; } } }
Finally, removing condition to always use template suggestion :
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 (!is_float($variables['element']['#weight'])) { $suggestions[] = 'input__checkbox__toggle'; // } } }
- Status changed to Closed: cannot reproduce
10 months ago 8:56am 10 January 2024 - 🇨🇭Switzerland saschaeggi Zurich
Closing as I can't reproduce these issues on the latest Drupal versions.