Forms used to edit relationship information always require that we edit something that already exists on the site. Two posts are usually connected based on custom fields that hold information about that connection, such as the track number of a song on an album. We can use Relationship Forms to edit this connection information.

Please note that Relationship Forms can edit existing connections between posts that are in a many-to-many relationship. They are not used to edit actual posts.

Because we are editing existing connections, editing forms always must appear inside templates. These templates (template layouts, or Content Templates) allow us to edit the connection that is being displayed. Let us examine how to create these forms, where to place them on our site, and how to link to them.

The process that we must always follow is:

  1. Create a template that we will use as an “editing-mode” for the content or relationship. (This is explained in greater detail  below.)
  2. Create a Forms Relationship Form.
  3. Include the form in the newly created template.
  4. Link to the form from a View that lists the items that can be edited.

The following diagram illustrates how this works.

View and Form for editing connection information between two items
View and Form for editing connection information between two items

1. Creating a template for use as an “editing-mode”

First, we must create a template in which we will insert the link to our form for editing existing connections between posts. This “editing-mode” template is displayed only when users click on a link to edit a relationship for a specific post.

Create a template layout but do not assign it to any content. If you are not using Toolset Layouts, create a Content Template and again, do not select any post types for it.

2. Creating a Toolset form for editing a relationship

Now, we must create a form that will edit the connections between posts in a relationship.

The form creation process is a bit different, depending on whether you use Toolset Layouts or not.

3. Inserting the form into the “editing-mode” template

If we use Layouts, we can skip this step because in the previous step, we created and inserted the form into our template layout.

If we do not use Layouts, we can go back to the “editing-mode” template we created in the first step and insert our Relationship Form.

Edit our template and, in the Template editor, click the Toolset Forms button. In the pop-up dialog that appears, click to insert the Relationship Form created in the previous section.

Finally, we must insert links to the “editing-mode” template we created in the previous steps.

We should insert these links into a View that lists related posts, for example, a View that lists all tracks of an album.

This means we are now linking to a form that will edit a relationship connection. Each listed post (Track) will have a dedicated link to edit its connection to an album.

Next, we must edit this View. The link to our “editing-mode” template must be inserted in the Loop Output Editor section. The screenshot that follows shows our template for this View before inserting the link.

Click the Toolset Forms button and a pop-up dialog appears. In the Relationship Links section, click to insert the link to your Relationship Form.

Another dialog showing options for the Relationship Form appears.

Select the last option to “Edit an existing connection” between related posts. Then, select the “editing-mode” template created in the first step and click the Insert shortcode button.

We are finished! Each post listed by our View will now include a link to the form that edits the connection between that post (i.e., a song) and its related parent (i.e., an album).

Deleting existing connections between posts

As previously noted, editing existing connections allows us to edit only the connection’s custom fields (e.g., a track number). However, removing an existing connection between two posts is often desired.

We can insert links for deleting existing connections into a View that lists connected posts. In our example, a link would be inserted into a View that displays a list of songs contained in the current album.

  1. Edit the View and click the Toolset Forms button in the Loop Content Editor section.
  2. In the dialog that appears, click the Delete relationship button.

  1. In the final step of the insertion dialog, select the post relationship in question (i.e., album tracks) and what happens after the deletion. For example, we might reload the current page so that the connection that was just deleted is no longer listed.

Now, each listed item will feature a link that allows users to delete the connection in question.