0

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

2
  • 2
    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.
    – Adrained
    Dec 21, 2022 at 20:07
  • 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.
    – prkos
    Dec 30, 2022 at 23:41

1 Answer 1

0

As you've discovered Inline Entity From saves all the referenced entities on the final save, so you'd need to add fairly complex handling to carry its form state to page two.

If I was doing this, I would consider using a pure JS solution for your two pages, where you show and hide fields as desired. The IEF processing is pretty fancy and I wouldn't want to mess with the setup it has.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.