Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
For the conditions added by other modules (e.g. Rules), when the conditions have mandatory contexts with select fields, the switch entities can not be saved due to the following error.
An illegal choice has been detected. Please contact the site administrator.
Steps to reproduce
- Install Rules module.
- Go to Structure > Switches
- Create a new switch.
- Select "Manual" Activation Method.
- Hit save
- The following error is observed
Proposed resolution
- Disable the required validation for fields which are not visible and are mandatory select fields.
- Assign "#empty_value" attributes to the mandatory select fields
Comment | File | Size | Author |
---|---|---|---|
#5 | switches-illegal_choice_has_been_detected-3238790-5.patch | 1.76 KB | sushyl |
#3 | switches-illegal_choice_has_been_detected-3238790-3.patch | 1.57 KB | sushyl |
| |||
#2 | Mandatory-Switch-Rules-error2.jpeg | 615.59 KB | sushyl |
Comments
Comment #2
sushylComment #3
sushylComment #4
sushylComment #5
sushylThe previous patch had a regression that was overriding existing values in the form.
Correcting it in a new patch.