Each fulfillment needs 3-4 child posts added which requires quite a few page reloads as the child posts can only be added one at a time.
What I'd like to know is if there is anyway with CRED to add multiple child posts to the fulfillment with a single form.
What I'd envisage is the entire CRED form would display as normal and an "Add additional Child" button would display at the bottom similar to the functionality of types fields that have the "Allow multiple-instances of this field" option checked.
When submitted the CRED form iterates over these and creates the multiple child posts.
If this isn't possible natively but it would be possible to do using the CRED api I'd love some direction as to how to start building this including which hooks I should be using. Any code snippet examples would be greatly appreciated.
Thank you for contacting us here in the Support Forum and for providing the Debug Informations
Each CRED form creates a single post with it's specific values stored.
If you want to submit multiple posts, you need a value for each of those CRED forms, let's say just minimal, the Post title
This is why you can not create multiple posts with one Form out of the box.
The most difficult is to have a feature that allows you to choose dynamically how many Child posts you are going to create.
If you have a limited number it would be very easy, as example with a Bootstrap Collapse Button on the "Create child CRED form" holding page, that holds all Child Forms you want the user to be able to create.
The user can submit the first form and you redirect him to the same page and so on
It could even be without the Bootstrap Collapse, by just redirecting after each submit to the correct "Create Child" page
It requires a page reload though, and the Posts aren't created all in one bunch.
With repeating Fields you could theoretically allow the user to add as many items of a certain field as he wants and then get this information to create Posts with the API, as example you have a Repeating Single Line Field and use the data to create (wp_insert_post) with each of the values.
the problem here is, the repeating field would be repeatable for each Field, not for each "post".
That means, your user chooses as example 2 "Titles", and then he goes on and chooses 2 Images, etc.
But it would not be a "good user experience", as the suer must think of both (or even more) posts simultaneously and not one after the other.
Also, some Custom Fields can't be repeated, such as Post Body or WYSIWYG.
I do not see any good and User Friendly way to add dynamically a certain amount of Posts with one form on the same "form"/page.
If your Posts can be the almost exact same though, I see a way of programmatically add (wp_insert_post) Posts with a red_save_data function.
You would as example set a Custom Field where you determine how many other posts the user wants to create.
You get this value and wp_insert_post for each of the values you already have, adding a "dynamic" extension to each, just like WordPress does when you create many posts with same title/slug
(post-2, post-3) or similar.
You could get the data from the "real", first form and enrich with eventually even values set in additional Fields the suer must set, if he wants more then one post.
I am eager to help, let us talk how "different" your content should be first, if that's OK for you?
So currently our fulfillments require either 3 or 4 child "Restaurant-To-Order" posts depending on the product ordered. I currently load the CRED create child post form (full wp page with the page template modified to only display the form) via Ajax onto the fulfillment layout and the form redirects back to the fulfillment page upon completion so only 1 page load is required per child post. But even this adds up when our operators have to process 10 or 20 orders at once (up to 80 child posts).
Each child post created needs 3 fields submitted: two drop down select fields and a number field. I currently display these in a row (See annotated image below)
So ideally I think I'd need a dropdown box to select the number of child posts to create (I could probably get smart and use jQuery to work out how many are required from the product name but manual selection would be fine for now).
That number would copy and create additional sets of form fields rows for the extra child posts. Then on submission we somehow need to process those additional rows.
Possible Alternative: Is there enough information on the fulfillment page itself to create a child restaurant-to-order post? As in could I build my own form outside of cred and pass it the fulfillment page id and run a custom function using php on submission: foreach "row" of form fields run wp_insert_post and add_post_meta to create the post and assign the relevant custom field data?