When we want to use our Relationship Form to create new connections between posts in a many-to-many relationship, we can insert it directly into any page or a template.
Please note that Relationship Forms are used to connect existing posts that are already in a many-to-many relationship. They are not used to create new posts.
Sometimes we may want to allow users to select posts from both “sides” of a relationship. For example, we might create a page called “Add Tracks to an Album” and insert our form into it. The following diagram explains this.
- Create a Forms Relationship Form.
- Edit a page on which to use the form and click the Toolset Forms button. Select our form in the Relationship forms section.
- An insertion dialog for our Relationship Form appears. Select what the form will do. In our example, to allow users to add any song to any album, we select “Connect between any Album and a Song” and click Insert shortcode.
In this manner, users will be able to select posts for both the parent (album) and child (song).
In many cases, we will already know one “side” of the relationship. For example, when displaying a single-album post, we might add a link to “Add New Songs to this Album.” Thus, the album side is “known”; it is the album we see right now. Therefore, in this case, we allow users to add any song to a preselected (i.e., the current) album.
In this case, it makes sense to include a link to this form in a template. When users click on the link, they will be taken to a separate page where they can add songs to the current album. The following diagram illustrates how this works.
Use the following steps to create this type of Relationship Form:
- Create a template for displaying single-album (parent) pages.
- Create a new Relationship Form and follow the wizard to select its settings and content.
- Create a template that is not assigned to anything and insert only the newly created Relationship Form. If you are using Toolset Layouts, do this by inserting a Forms Relationship Form cell.
- Edit the template created for displaying single-album pages and click the Toolset Forms button. If you are using Layouts, insert the Visual Editor cell and click the Toolset Forms button inside that cell. Insert the link to the newly created Relationship Form.
- In the form-insert dialog, use the second option, Connect a Song to a given Album. In the options beneath, select Link to an existing Content Template that contains the form (if you are using Layouts, it will say “Layout” instead) and choose the layout you created in step 3, above.
We are finished! Now, when users view any parent post (album), they will be able to connect new child posts (songs) to it.