Skip Navigation

Selecting Parent Posts when Using Forms to Create Child Items

Toolset allows you to create front-end forms for creating new posts. If those posts are in a one-to-one or one-to-many post relationship, the form can feature a field for selecting the parent post of the one being created.

For example, you could have custom post types for “Events” and “Venues.” An event can have only one venue, whereas a venue can be used for many events. Your front-end form for creating events can feature a field for selecting a venue for the event being created.

Form for creating child posts with a selector for the parent post

Here we describe cases in which the post-relationship is either one-to-many or one-to-one. Visit the related documentation if you need to create forms for connecting posts in a many-to-many relationship.

Creating Forms that Allow to Select a Parent Post

First, let’s see a case where you create a form for submitting child posts (i.e. events) but you want to allow users to select a parent post of their choosing.

Once your post relationship is created, go to the Toolset → Post Forms page and create a new form. The usage is the same for forms that create new posts and the ones that edit existing posts.

When you create a new form, the element for the post relationship will be a part of the form by default.

If you need to insert the parent selector field manually for existing forms, go to the Form Editor section and drag-and-drop relationship in question to desired location.

Adding relationship fields to the form using the drag-and-drop editor

That’s it! Now, when users create new posts and select their parent posts, the posts will be connected.

Creating Forms with a Parent Post Preselected

When using forms to create child posts, the parent post will often be known. For example, you might have a button to add an Event to a Venue currently being displayed, as shown in the following example.

Venue post on the front-end with a link to a form for adding Events to the post

Follow these steps:

  1. Edit the Content Template for the parent post type (i.e. Venue).
  2. Insert the Toolset Fields and Text block and inside its editor, click the Forms button.
  3. In the pop-up dialog, click Create Child Post Link.
  4. Another dialog appears where you have to select the options for your link.
  5. In the Parent post section, make sure to select the option Set the parent according to the currently displayed content.

That’s it! Now, when a user clicks to add a child post, the form will automatically select the parent.

Main Toolset Block Used in this Lesson

Display standard and custom fields