Skip Navigation

[Resolved] Not all relationship are listed on to "Add Field at the Form" box

This support ticket is created 4 years, 2 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 7 replies, has 2 voices.

Last updated by Beda 4 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#1509121

I am trying to: create two forms, the first to add a new CPT "FoR" post, the second to edit the CPT "FoR" post.
Before, I have created the forms to create and edit the standard post type.
The standard post type has a relationship with the CPT FoR, 1 CPT FoR => many standard post type.
Also, I have another CPT called Comuni, this CPT has in the relationship "one to many" with standard post type and with CPT FoR.

When I have created the forms for the standard post type, I can see and insert both relationships field in the Forms.
To create the forms for the CPT FoR that are identical to the standard post type forms, I have cloned the standard post type forms, but when I enter to edit the "CPT For => standard post type" Relationship field, in the box to select the fields to add in the form, in the relationship section I can see only the "CPT Comuni => CPT FoR" relationship field...
But I expected to see all relationship fields, like in the standard post type form editor, and I don't know how I should do to set the relationship that I need!!!
In the shortcode related the relationship from the "add a new standard post type" I have tried to do some change from

[cred_field field='@festival-rassegna-articolo.parent' class='form-control' output='bootstrap' select_text='--- non impostato ---' author='$current']

to

[cred_field field='@festival-rassegna-articolo.child' class='form-control' output='bootstrap' select_text='--- non impostato ---' author='$current']

but it don't works...

Why I have this and what should I do to solve it?

#1510083

That is expected, you can - when you create any post - only connect to one item a time (the parent) and not to potentially many items at once (in your case the native post type which is a child to the for post type you created).

What you classically do in such cases is:

1. Have a form that creates child (the "many" end of the relationship, in your case native posts) where you can select one related post when submitting the form (in your case the parent "for" post)
2. Have a form that creates parent posts - however here you'll not be able to select any related Child Posts.

The workflow suggested, is usually like so:
1. Insert the Form that creates a "parent" (the post type that can have only one post in a relationship)
2. When that form submits, redirect it to the created Post, where you offer links or forms to add (many) child Posts
3. The link or form used for this should be a form that creates child posts, and you can then submit one child a time, connecting it to one parent a time.
4. You can redirect that form back to the origin or just keep displaying it, so the user can then add more and more child posts.

Does this help?

#1510277

Thank you,
This helps me.

So, I have other questions:
Well, I create the form to add the parent post (without the relationship field), after the save the users are redirected to the form to create a new child post and here the users can select the parent post related. But it could be select automatically from the system because the users are here in this add child post form after they are added the parent post with form?

Now, after the child post saves, the users will be redirected to add new child posts... and so on... Well, if I want to come back to modify the parent post or the other child posts created before from the form to add a new child post, how should I do to have the correct links and is it possible to do that?

And, after I have created all child posts and related them to their parent post, when I will try to edit the parent post using the modify post form, here can I have the child relationship field to list which child posts are related and can I delete or de-related one of them?

#1510289

Yes, this can be done.

Generally, you would redirect from the "create" post form to the post, and there offer a link to create more "child" posts.
This corresponds to the "Create Child Posts link" in the Forms GUI, which if inserted to a post, or content template asigned to posts, will ask you to specify a target page.

This target page should be holding the actual "create" form for the child posts.
The GUI of Toolset Forms will offer you several options to specify the parent, one of them is "defined by the current post".
This means the link will pass the Post ID to the Form that creates child posts automatically.
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected

You cannot edit related posts in the "parent" form, that is not possible.
You can list related posts, with a View, this would be possible, as long the post exists (speak, you are using it in a Form to edit already connected parent posts)

You'd always manipulate the post connection in the "child" forms.
You can also use the Relationship forms, instead of Post Forms, to manipulate connections.
This is done in Toolset > Relationship Forms.

But those forms won't allow you to create posts, instead, only to connect or disconnect posts.
Maybe these help to make the workflow more intuitive, but I must warn that these forms can't take notifications, or Custom Code API Calls at all.
Only Post and User Forms could do that. This might be useful to know if you plan to add custom logic to the process.

#1514319

Thank you,
I will test this solution today!

#1514321

Thanks, let me know if something remains unclear.

#1518243

Hi Beda,
I have added the "Create Child Posts link", and this does what I need.
For now, I display all child posts list in the related parent post, and this is ok for me. after I will try to add the edit post link into every single posts list item that are listed in the parent post, that is visible only for the author of the posts.

#1518269

OK, great

please let me know if you need more help

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