Not required image field is required when visible, despite not defined

Created on 23 December 2024, 28 days ago

Problem/Motivation

I have an upload field field_documents (for images, if it may be relevant) on a node. When viewing, the field is not required and shown in a collapsible.
Next, I've added a conditional field for field_company, a boolean. When it's checked, the field_documents should not be visible. And vice versa.

When I check my form, the field field_document is not required, but the field widget however is.
If I check field_company, it gets optional, but when I uncheck it, it goes back to required, despite having nowhere defined it should be required.

Steps to reproduce

  1. Add content type
  2. Add an upload field to content type (not required)
  3. Add a boolean field to content type (not required)
  4. Check the form (and see the field is not required, nor the widget)
  5. Add the upload field as the target field
  6. Add the boolean field as the control field
  7. Add a visible state when control field is checked
  8. See the form and see the widget as required, despite not having the boolean checked

Proposed resolution

Make it not required, if the default state is not required.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇧🇪Belgium blacksnipe

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

Comments & Activities

  • Issue created by @blacksnipe
  • 🇧🇪Belgium blacksnipe

    Found the issue with the help of a colleague.

    There was a required conditional state on the field grouping where the field was added.
    When I removed it, the widget was no longer required.

    Leaving this for future reference.

Production build 0.71.5 2024