Required is cannot be false

Created on 29 July 2025, 4 days ago

Problem/Motivation

Even if required is unchecked, field is always required.
empty(FALSE) will return FALSE.

There is also some conditions which make impossible to set a field as not required if it's configured as required in storage definition.

It's should be the purpose of this module to allow to disable the required settings for a form mode in some specific case.

In my case, a field is required BUT in specific form mode for specific bundle, i don't want it to be required, i'll set value later.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡«πŸ‡·France goz

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

Comments & Activities

  • Issue created by @goz
  • @goz opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States clayfreeman Paragould, AR

    This module does not intend to make it possible to set a field as optional when it's already required. Doing so would likely lead to adverse side effects (e.g., implicit NotNull constraint validation errors). On the other hand, making an optional field required for specific form modes is safe because it only has implications when rendering the field widget on the form.

    If the option to mark a field as "Required" in the form display is appearing when it shouldn't be, I'd happily accept a patch to fix that. I'd also accept any suggestions you may have for updating the project description to clarify this design choice should you believe it to be necessary.

    I'm closing this issue in the mean time.

  • πŸ‡«πŸ‡·France goz

    Thank you for your quick answer.
    I effectively saw this logic (from code and tests). That's why i suggested to add in description a warning that a default value should be defined in case required was originally TRUE.

    Can you at least check "required" works ? As i explain in the issue, !empty($settings['required']) will always return FALSE except if there is no required key in the array, so definition will never be overriden.

Production build 0.71.5 2024