Checkbox/radio widget shows multiple selections even though it should only allow one

Created on 28 December 2023, 11 months ago
Updated 16 January 2024, 10 months ago

Problem/Motivation

I have a taxonomy entity reference field where the settings are set to unlimited values, while the third-party setting limits it to 1. It works as expected with the select form widget, but it doesn't work with the checkboxes/radio buttons form widget. The selection continues to allow for multiple choices. This issue persists not only with taxonomy fields, but also extends to list text fields.

Steps to reproduce

1) Create a taxonomy entity reference field.
2) Set the field settings "Allowed number of values" to unlimited.
3) Save.
4) Edit the field again, then set the "Allowed number of values (Cardinality Instance)" limit to 1.
5) Save.

Proposed resolution

Use hook_field_widget_single_element_form_alter to change the element type from checkboxes to radios.

🐛 Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

🇵🇭Philippines madelyncruz

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024