Non-mandatory fields rendered as radio group throw validation error if no option is selected

Created on 11 May 2023, over 1 year ago

Problem/Motivation

I have the problem that the field validation isn't correctly built in Drupal, it seems. I have a field using the following configuration:

  • not mandatory
  • type entity reference => lists taxonomy terms of a certain vocabulary
  • no default value given
  • rendered as a radio group

Now when I add this field to form display of some node and select no option, I get a validation error. The radio group is rendered having my 3 options (of the taxonomy vocabulary) and additionally a n/a option with the value "_none".

Selecting nothing results in a validation error (which is a bug in my opinion). Selecting a value or n/a works, no validation error anymore. *But* when selecting n/a, this special value "_none" isn't stored to database so when returning to the node edit form later on, I get the same issue again and would *everytime* have to select the n/a option.

Of course, I could make the field mandatory so that the n/a option disapears and one must select a regular option. But since it's a new field also for existing nodes (thousands), this isn't ok because then the editors would have to select an option everytime they edit something else, as well which is very annoying.

Proposed resolution

In my opinion, the validation shouldn't fail if a non-mandatory field isn't filled out. I would remove this.

Any advice is highly appreciated, I hope I described it well enough to understand ;-)

Bye

🐛 Bug report
Status

Active

Version

9.5

Component
Field 

Last updated about 4 hours ago

Created by

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

Comments & Activities

Production build 0.71.5 2024