[Resolved] Cred form for repeatable group – only allow to add to current post
This thread is resolved. Here is a description of the problem and solution.
Problem:
A form to add repeatable field groups includes a selector to specify which post they belong to. How to pre-select that post?
Solution:
Repeatable field groups are implemented as child posts of the post to which the fields belong, and the normal workflow for adding child posts where the parent is predefined is described in the linked documentation.
In this case, the client was including the forms to add repeatable field groups directly in the output of a View, in which case the parent post could be specified by using the wpv-post-id shortcode to provide the default value for the selector.
I have an order cpt with repeatable group for notes.
I have created a cred form for creating new "notes", but the cred form only allows me to choose which post i want to add the notes to, whereas I need it to allow posting new repeatable notes ONLY FOR THE CURRENT POST.
Is there a way to make the cred form NOT display the select box for choosing a post, and only allow to use this in the current post, similar to showing only the current author?
The repeatable field groups are implemented using child posts, so setting the post to which the repeatable field group belongs is done in the same way as pre-selecting which parent post a child post belongs to.
Still stuck. I think nowhere in the documentation does it say anything about "current post".
The relationship field in repeatable field form doesn't the ability to determine the current post...
The expected workflow is that you are viewing a parent post (or the post that the RFG will belong to) and that the template for these posts includes a link to the form to add child posts.
You can insert such a link using the Toolset Forms button and Create Child Post Link, where in the resulting dialog you specify that the parent will be the current post where the link is inserted (screenshot).
i have a view with a table showing all orders (posts).
in the table, there's a td which includes the "add notes" form, which is just a cred form for creating the repeatable field.
when i try to insert a child post link into the view, i can't see the form in the choice area.
is this because it's a view and not the content template of the order?
is there a way to insert such a link into a view displaying all orders?
thx!
OK, slightly different, as you are including the form itself (multiple times, once for every post, or row of the table).
In which case you can edit your form which will include a field for the parent selector, and you can provide the default value which should be the ID of the parent post—the current post in the loop—so insert the wpv-post-id shortcode, which will provide the ID of the current post in the loop.