Score:1

Why the form does not save data from the entity reference field?

qa flag
tim

I have a custom entity (with the name Entity Quote), from the add form of this entity I make a multistep form.

In the custom entity Entity Quote, I added another custom entity (with the name Quote Design) as a reference field(with the name Design) to add the form of the second custom entity Quote Design to the second form step of the first custom entity Entity Quote. And I implemented adding the form of the second custom entity using the module Inline Entity Form:
https://www.drupal.org/project/inline_entity_form

Where for the reference field I chose in the Manage Form Display the widget: Inline entity form - Complex

enter image description here

But the problem is that only the fields on the first step of the form are saved where the fields of the first custom entity (Entity Quote), on the second step where the two fields of the second custom entity (Quote Design) the data is not saved. The data is not in the tables and, accordingly, is not in the UI either.

The save() method is executed after pressing the Save button, which appears on the second step of the form.

Implementation of multistep form (Entity Quote add form) in sandbox:
https://phpsandbox.io/n/divine-grass-1doo-ylab7

Adrained avatar
gb flag
I would look at the objects passed to the save element -- does the form contain a target_id in field_design? I'm not sure what else you'd have to do if its not, but that's a good place to start. Also, just as a clarification, do the Quote Designs already exist, or are the created as you create an Entity Quote.
mx flag
I'm sorry if I'm asking something you're already aware of, but where are you checking for the saved data of the Quote design? It will not be saved along with the Entity Quote data. They are in separate places (db tables). The Inline Entity Form enables the simultaneous creation of 2 separate entities. Entity Quote will save only the **reference ID** to the Quote Design, it will not save all its data. Quote Design data is saved in Quote Design entity item.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.