UX problem in forms with referenced entities.

Created on 1 February 2024, 11 months ago
Updated 2 February 2024, 11 months ago

Problem/Motivation

I noticed, that using forms becomes difficult, when forms contain inline forms of referenced entities, which are not required, but the fields in the referenced entity are.

Steps to reproduce

Lets say you have an content entity for cooking recipes, which have title body and a NON (!) REQUIRED, unlimited values field of ingredients which happens to be a storage entity which contains of 3 REQUIRED fields (amount, name and unit). As we are all humans, we set up the entity form this way, that the ingredients are shown inline (with add more and remove per line), thus the recipe can be entered in one step. ( https://www.drupal.org/project/storage/ )

Now comes the problem (which I face): The entity should be savable with only the entered title. Because body and ingredients are not required. But that is not the case. Because the Drupal form UI always shows (from unlimited fields) the fields to enter (here the ingredients) they are required and the entity can't be saved. It is not possible to remove the unused _row_ to trick Drupal into just having no ingredients so far and be done with it.

I know that there might be form widgets to select the reference from a list or autocomplete it, but who enters recipes like that?

Proposed resolution

Idk, maybe a checkbox to mark the first row of an reference and NON-REQUIRED field as _empty_.

Feature request
Status

Closed: duplicate

Version

10.2

Component
Form 

Last updated 3 days ago

Created by

🇩🇪Germany ro-no-lo

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

Comments & Activities

Production build 0.71.5 2024