Don’t forget to subscribe to our YouTube channel to stay up-to-date.
If you create an entity reference or list field, you will notice the “Check boxes/radio buttons” widget on the “Manage form display” page.
How do you switch between checkboxes or radio buttons? Because the widget has no settings to choose the form element.
Drupal automatically switches between the elements depending on the “Number of values” option on the “Field settings” page.
Create List Field
Let’s first create a list field with options.
Display Widget as Radio Buttons
If the “Allowed number of values” is set to 1, which can be changed by editing the field and clicking on “Field settings” and changing the configuration..
Then the widget will be displayed like the following:
Display Widget as Checkboxes
If you want your field widget to use checkboxes then change the “Allowed number of values” to 2:
Or instead, select Unlimited:
Then it’ll display as checkboxes:
The “Check boxes/radio buttons” widget switches between form elements based on the field’s “Allowed number of values” settings.
If you want it displayed as a radio button, limit it to 1. If you want checkboxes, change it to unlimited or limit it to 2 or above.
Frequently Asked Questions
How to add checkbox in Drupal?
Create a list or entity reference field, then change the “Allowed number of values” to unlimited or limit it to 2 or above. Make sure you select “Check boxes/radio buttons” as the field widget.