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 firstname.lastname@example.org' class='form-control' output='bootstrap' select_text='--- non impostato ---' author='$current']
[cred_field email@example.com' class='form-control' output='bootstrap' select_text='--- non impostato ---' author='$current']
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.
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?
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.
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.
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.