Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
If you create a form and make that some checkboxes have an ajax actions (for example, when you check one checkbox, another field will be updated), the checkbox renderization are buggy.
See the attached image for more details.
This is the form field definition:
$form['country'] = [
'#type' => 'checkboxes',
'#options' => $countries,
'#ajax' => [
'callback' => [$this, 'rebuildProvinces'],
'event' => 'change',
'wrapper' => 'edit-province',
],
];
Comment | File | Size | Author |
---|---|---|---|
#6 | 2762225-6.patch | 1.22 KB | markhalliwell |
ajax_rendering.png | 56.35 KB | estoyausente |
Comments
Comment #2
markhalliwellPretty sure this has something to do with the JavaScript ajax handling in http://cgit.drupalcode.org/bootstrap/tree/js/misc/ajax.js or some other JS file where it's trying to wrap in an input group (so it looks decent); like with select elements.
Comment #3
torgosPizzaI think is may be a duplicate of #2121203: Better Exposed Filters Checkboxes.
Comment #4
fearlsgroove CreditAttribution: fearlsgroove at Alloy Magnetic commentedCheckboxes simply don't work in input-groups with ajax, mostly because they're wrapped in labels. Theoretically you could drastically alter the markup to accommodate it, but it's not really worth it. Attached patch excludes checkbox(es) from the input-group processing. Should probably also happen with radios.
Comment #5
markhalliwellElement::isType can take an array of strings, no need for multiple invocations of the method.
May as well go ahead and put radios in here as well.
---
I'd also like to see a screenshot of a before and after with this patch applied so I can see the visual difference.
Comment #6
markhalliwell