Hi,

I have recently updated the Bootstrap Barrio version and I have verified that for some reason the checkboxes and radios of my forms have disappeared.

If I try to use the form autocomplete option (I use the Webform module) it will autocomplete and it will be sent including the checkbox or any radio button present but I do not see the checkbox or radios nor click on it.

If I change the theme (for example default Drupal theme) the checkboxes and radios reappear, so I tried to uninstall Barrio and reinstall it but nothing happened.

Any ideas?

Best regards.

Comments

chema_ created an issue. See original summary.

chema_’s picture

Title: checkbox » checkbox and radio buttons
Issue summary: View changes
hatuhay’s picture

If no error messages on Drupal or JavaScript, I suggest to check if custom buttons are enabled.

chema_’s picture

hi hatuhay

how do I check if custom buttons are enabled?

hatuhay’s picture

I mean "form widgets":
/admin/appearance/settings/SUBTHEMENAME
Components -> Form

chema_’s picture

that was the problem.

thanks hatuhay

jurgenhaas’s picture

Category: Support request » Bug report
Priority: Normal » Critical

I just ran into the same problem that checkboxes and radio buttons can no longer be selected by clicking on their label. After some investigation I found out that the reason is that the label element is missing the "for" attribute. This must have to do with templates/form/form-element.html.twig file and I'm looking further, how to fix that.

jurgenhaas’s picture

OK, the problem is that

<label {{ label_attributes.addClass(labelclass).setAttribute('for', input_attributes.id) }}>

does not output any attributes. I don't know why that is but as a quick fix and workaround I have changed that code to

<label for="{{ input_attributes.id }}">

which at least outputs the "for" attribute and brings back proper functionality.

lawxen’s picture

StatusFileSize
new64.27 KB

I have this issue after update bootstrap barrio

lawxen’s picture

StatusFileSize
new47 KB

Config like this make my layout builder's checkbox can work

bunty badgujar’s picture

Status: Active » Needs review
StatusFileSize
new911 bytes

For some reason variable "input_attributes.id" is not set in "bootstrap_barrio_preprocess_form_element" and setAttribute('for', input_attributes.id) doesn't return empty attribute.

Here is the commit where condition added :- Git commit [Issue #2892364]

Patch to return empty "for" attribute if input_attributes.id not set in preprocessor.

Smokvin’s picture

/admin/appearance/settings/SUBTHEMENAME
Components -> Form

Custom type does not work.
Patch above can fix the clickable area for Standard type label, but Custom type has still invisible checkboxes (only labels are visible).
It looks like the real checkboxes are hiding with css, but Bootstrap4 custom pseudo-checkboxes do not appear on the page.

5.0.0-beta2

dropa’s picture

I can't relate to the original issue, but I came here because of #3137559, after which checkbox labels has no parameters at all.

Can confirm #11 fixing the issue I'm having. My exact issue was that behat test couldn't find checkbox from the site (also using webform) since label was missing "for" attribute.

aalin’s picture

StatusFileSize
new487 bytes

I confirm that this is related to #3137559
The issue is that checkbox labels are using label_attributes which is not initialized.
Patch added to initialize it and to use an optional #label_attributes key element.

ccarrascal’s picture

I have the same problem, after updating to 4.30, the attributes for the labels are gone, and patch in #14 is working for me with Drupal 8.9.1.

Thanks a lot!

ccarrascal’s picture

After checking the other issue #3137559 , I am thinking that probably a better fix for this issue will be just initialising the label_attributes in the template itself, as it's done in the other ticket:

+{%
+  set label_attributes = create_attribute()
+%}

Any comments on this?

ruslan piskarov’s picture

Title: checkbox and radio buttons » Checkbox and radio buttons
michèle’s picture

#12 + #16
Adding {% set label_attributes = create_attribute() %} to the form-element.html.twig Template (in a subtheme) fixed custom checkboxes!

Many thanks!

volker23’s picture

Patch in #14 works.

ccarrascal’s picture

StatusFileSize
new459 bytes

I am submitting a patch following my comment in #16.

What i am doing is checking if the label_attributes variable is initialised in the template file. This has two benefits:

* The value of the variable can still be preprocessed, but there is no initial need for it.
* If the preprocessing somehow removes or set to null that variable, the template will still works.

I have tested it in my site and seems to work fine with 8.9.1
Thanks

  • hatuhay committed 6b4f6fc on 8.x-4.x authored by ccarrascal
    Issue #3153447 by ccarrascal, Bunty Badgujar, aalin, lawxen: Checkbox...

  • hatuhay committed 6a5131d on 5.x authored by ccarrascal
    Issue #3153447 by ccarrascal, Bunty Badgujar, aalin, lawxen: Checkbox...
hatuhay’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.