Required fields make an optional IEF (erroneously) required

Created on 9 December 2019, almost 5 years ago
Updated 16 August 2024, 3 months ago

This might be a feature request, as to my knowledge it's not something doable, but some communications have indicated it is, so maybe I just need to find a proper setting in UI.

I have a content type with an optional entity reference to a second content type. The second content type contains required fields. I would like to be able to use IEF in such a way that the creation of the referenced entity remains optional. If this is possible, I would like to know what settings are necessary. If it's not possible, I would like that verified, and have this noted as a feature request.

My current settings:
The entity reference field is not required. It references a single content type, allowing the creation of new entities. Multiple references are allowed.
The form display of the parent can be set to either Inline entity form - Simple or Inline entity form - Complex. Setting the form to collapsed and/or collapsed by default has no effect on the observed behavior.

The referenced entity includes several required fields, because if one is created, it must have those fields.

Observed behavior:
It is impossible to save a parent entity without a reference to a child.

Expected/Desired behavior:
To have some mechanism of saving a parent without any reference, since the reference is optional.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States msypes

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡»πŸ‡³Vietnam linhnm

    Reroll #15 for version 2.0.

  • πŸ‡ΊπŸ‡ΈUnited States dcam

    Adding related issue.

  • πŸ‡ΊπŸ‡ΈUnited States zengenuity

    Re-roll for 3.x branch.

  • πŸ‡ΊπŸ‡ΈUnited States sidgrafix

    +1 (used patch #15) Drupal 10.3.2 and inline_entity_form 8.x-1.0-rc17

    Saved me after days of trying to get a field that should NOT be required when the field is part of a media entity using the inline entity form as an option on the content type edit/add form. Specifically when media entity type reference field "video" is used if a video wasn't uploaded a name shouldn't be required. Which cause other issues (as a workaround even tried) including a name when no video file was uploaded which then caused the media entity to be created and it shouldn't have been.

    ...Frustrating to say the least and the cause of a wicked headache until I finally realized inline_entity_form was causing the overall issue and finally stumbled onto this thread.
    (but this is definitely needed) - thought I was going to have to dive into declaring an inline entity form controller for media to get it to work right after having tried every conceivable hook and callback to try and alter the fields #required state to FALSE (almost went with disabling default validation) for the entire node form on submit and validate it all in a callback - so glad I found this instead!

    Also tried inline_media_form but that made things worse plus had to download it and add drupal 10 in it's info file just to try it.

Production build 0.71.5 2024