Checkboxes broken

Created on 27 November 2017, almost 7 years ago
Updated 27 September 2023, about 1 year ago

Checkboxes are not being handled correctly by conditional_fields/src/Plugin/conditional_fields/handler/OptionsButtons.php - tried in Druapl 8.3x and 8.4. Specifically:

protected function checkBoxesHandler($field, $field_info, $options) {

No longer works with the fields correctly as they are being rendered differently by Drupal 8.

An admin will get the following error messages when they try to work on forms:

"Notice: Undefined index: #return_value in Drupal\conditional_fields\Plugin\conditional_fields\handler\OptionsButtons->checkBoxesHandler() (line 107 of modules/contrib/conditional_fields/src/Plugin/conditional_fields/handler/OptionsButtons.php)."

This will not terminate form handling, however it will stop any conditional field settings from being applied, and will just show everything in the form as normal regardless of any conditional field settings applied.

Form fields do not have the right visibility metadata appended for example they have:
visible="[name=\u0022field_solution_type[]\u0022]"
instead of "[name=\u0022field_solution_type[]\u0022]":{"value":["24"]}}"

I am looking at a fix to this myself in the meantime for an urgent project and will get back with my findings, however you are probably likely to be able to produce a more stable patch.

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇬🇧United Kingdom xiss23

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024