Milos Cuculovic
Milos Cuculovic

Reputation: 20223

Symfony: How to use the object from the form which is not yet in the database

I have three entities:

In the form, the user can create a new person and add some existing affiliations by clicking the button (add existing affiliations). The existing affiliations will be added in the PersonAffiliation entity.

The problem is that when the user starts creating a new person, he has to click add existing affiliation, and this person is not present in the database yet.

Is there a possibility to use the Person object from the form in the second form during the affiliations selection and then set the selected affiliations to this Person object and come back to the first form where the user has to submit the Person creation.

Tank you very much for your help.

Upvotes: 0

Views: 98

Answers (1)

Patrick James McDougle
Patrick James McDougle

Reputation: 2062

You can do this two possible ways:

  1. is called an embedded collection of forms. You can read about it in the Symfony documentation. It isn't very easy to find if you don't exactly know what to call it.
  2. Create the Person form and upon successful completion of a Person submission, then redirect to an Affiliation form with the person ID already filled in.

Upvotes: 1

Related Questions