Multiple-value checkboxes do not render existing values

Created on 18 September 2020, almost 4 years ago
Updated 23 February 2023, over 1 year ago

Problem/Motivation

When a Select Or Other field can contain multiple values and uses checkboxes, existing values are not preserved - the boxes are not checked when you go to edit the field.

Steps to reproduce

Create a list-text field that can take multiple values. Add Select Or Other as the form widget, and choose checkboxes. Create a piece of content with one or more boxes checked. Edit content - prior choices are not preserved in widget. (If you change the widget to a select_or_other select list, it works).

Proposed resolution

The bug appears to be in Element/Buttons.php::addEmptyOption(). At line 86, an "else" statement as been added in the most recent release. Within that else, you find a scary statement: $element['select']['#value'] = []; If you comment out that "else", it works.

Remaining tasks

Figure out why that code was added in the most recent release, and what breaks if the else statement is removed.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States gbirch

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.69.0 2024