Skip Navigation

[Resolved] One-to-many relationship posts: Front-end form to create items in BOTH types?

This thread is resolved. Here is a description of the problem and solution.

Problem:
My site won't be dealing with events or venues, but for the sake of simplicity and clarity in asking my question I'm going to use the event (child) / venue (parent) example that you use in your documentation.

Is it possible for users to add child AND parent items at the same time via a front-end form? Or link several forms if necessary in a streamlined way?

If the user was trying to add an event, could they
1. Determine whether the venue (parent) already exists on the site
2. If the venue (parent) does NOT already exist, they would add the venue (parent) AND the event (child) to be assigned to the venue
3. If the venue (parent) DOES already exist, the user could select the venue from a list and then add the event (child) to be assigned to the existing venue.

Ideally, I'd like to have a form which starts with a simple search field, where the user could quickly type in the name of the venue to see if it's already in the system. If it's not, then a field would appear where they could type in the name of the venue and click "Add", then "Add an event at this venue."

If the user added a new venue, then a new Venue profile page would be created and the new event would be associated with that venue in a one to many relationship.
If the venue already existed, then the new event would be added to the existing venue's profile page.

Solution:
Currently, it is not possible to create two posts with one form, you can only create one post at a time. But you can still get this workflow using views and two forms:
- A view to search for current venues.
- A form to create a venue, if it does not exist.
- A form to create an event linked to a venue.

First, you will create the view, and add a search field to it, and inside the loop of the view, you will put the 2nd Form(relationship form) or a link to it. This way, if the venue already exists, the user will use the form directly on inside the results of the search, or you can provide a link to the form, and the user will click to link to go to the form, then he can create the event linked to that venue.

You can configure the view to display the 1st form(create venue) if no venues are found, then you will configure the form to redirect the user to the 2nd form content template where he can create the event.

This support ticket is created 3 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by Lauren 3 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#1786997

I'm reading this documentation: https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/

My site won't be dealing with events or venues, but for the sake of simplicity and clarity in asking my question I'm going to use the event (child) / venue (parent) example that you use in your documentation.

Is it possible for users to add child AND parent items at the same time via a front-end form? Or link several forms if necessary in a streamlined way?

If the user was trying to add an event, could they
1. Determine whether the venue (parent) already exists on the site
2. If the venue (parent) does NOT already exist, they would add the venue (parent) AND the event (child) to be assigned to the venue
3. If the venue (parent) DOES already exist, the user could select the venue from a list and then add the event (child) to be assigned to the existing venue.

Ideally, I'd like to have a form which starts with a simple search field, where the user could quickly type in the name of the venue to see if it's already in the system. If it's not, then a field would appear where they could type in the name of the venue and click "Add", then "Add an event at this venue."

If the user added a new venue, then a new Venue profile page would be created and the new event would be associated with that venue in a one to many relationship.
If the venue already existed, then the new event would be added to the existing venue's profile page.

I hope that makes sense....

#1787937

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting the Toolset support.

Currently, it is not possible to create two posts with one form, you can only create one post at a time. But you can still get this workflow using views and two forms:
- A view to search for current venues.
- A form to create a venue, if it does not exist.
- A form to create an event linked to a venue.

First, you will create the view, and add a search field to it, and inside the loop of the view, you will put the 2nd Form(relationship form) or a link to it. This way, if the venue already exists, the user will use the form directly on inside the results of the search, or you can provide a link to the form, and the user will click to link to go to the form, then he can create the event linked to that venue.

You can configure the view to display the 1st form(create venue) if no venues are found, then you will configure the form to redirect the user to the 2nd form content template where he can create the event.

I hope this makes sense. Let me know if you have any questions.

#1791639

I'm still working on implementing this. Will post back if I have any further issues. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.