Drupal add content in another content's form

375 views Asked by At

I'm using Drupal 7 and I'm currently facing the following problem:

I have a database that among other data consists of addresses and services. The relationship is such that every service needs to have an address (just one). In Drupal both addresses and services are content types and a service has a field that relates it to an address (using EntityReference module).

When creating a new service users can choose an existing address for it, but the address needs to be created beforehand. I would like to know of it's possible to create a content creation form for service that would contain all the fields for address as well. If the user would fill all the fields by hand, a new service and a new address would be created. There should also be an option to choose an address (from a list or suggestion box). Upon doing so the address fields would be automatically populated with data from an already existing address and, when submitted, the form would result in creation of a new service related to a previously existing address (just like it works now). I did a very similar thing in Django and it was very easy and didn't require a very application-specific code. I was wondering if there is a just as simple way to do it in Drupal.

To put it shortly - I'm looking for a service content creation form that gives the choice choice between choosing an existing address or creating a new one "in-place" (i.e. in the same form).

I would also like to add that I'm relatively new to Drupal (although I have php experience) and it's difficult for me to properly name the problem I'm facing. As a result it's quite possible that the title of this question is not relevant and/or this issue has been addressed in another question (and yes, I searched for it). If that is the case, feel free to just point me in the right direction.

Any help would be greatly appreciated.

Thanks!

1

There are 1 answers

0
Boriana Ditcheva On

The references dialog module should be just what you need! It should allow you to add a referenced node without leaving your current edit screen!

It doesn't place the fields right in there, but you don't have to leave the screen to create a referenced node.

Is this what you had in mind?