Hi there
I have a post type called styleguide that has several one-to-many relationships to add logos, colors, images and so on to the styleguide.
I created forms to create child posts with a parent post selector. That is working. However, it's never preselecting the parent. According to this post here https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items I assumed, that would work automatically. I have both tried opening the form with a link from the styleguide (the form is embedded on a normal page) and as a modal on the styleguide-page itself (inserted in the layout). Both times the parent isn't preselected. In fact in the modal the parent field doesn't show anything anyways. But as it's not even working on the page with the form for the child post, I assume I forgot something anyways.
In case it helps, here is one styleguide we created (its a work in progress so it's a bit messy): versteckter Link. At the bottom, there are two links to test (if you need an account, let me know).
Thanks for your help.
Best,
Marcial
Dear Marcial,
I assume you are displaying a Toolset form for creating child post in the single parent post.
If it is, you can setup the default value by setting "value" attribute of parent selector shortcode [cred-field], for example:
[cred_field value="[wpv-post-id]" ...]
More help:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
value. Optional. Preset value
Hi Luo
I'm afraid I need some help with this.
Option 1 (Popup): This is the shortcode in the popup window: {!{cred_form form='logo'}!}. Now you suggest to add a value like this {!{cred_form form='logo' value='...'}!}? What value is the current ID (must be dynamic) and how can I connect that with the parent post selector in the form?
Option 2 (link to page): I added the parameter like this: versteckter Link (75 is the ID of my styleguide). That doesn't work. Also "-1" doesn't work. Changing it to "?parent_toolset-api_id=..." didn't work (as shown in the example).
Can you help me with this?
Thanks,
Marcial
In a single "styleguide" post, you can get the "styleguide" post ID with Views shortcode [wpv-post-id]:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-id
And in a single "styleguide" post, you can display the Toolset post form for creating "logo" post.
In the Toolset post form for creating "logo" post, section "Content", find and edit the shortcode [cred_field] for rendering the parent selector, you can pass [wpv-post-id] as attribute "value", for example:
[cred_field field="@RELATIONSHIP-SLUG.parent" value="wpv-post-id" class="form-control" output="bootstrap" select_text="--- not set ---"]
Hi Luo
Awesome, I was able to get the modal to work.
For the second attempt (form is on a separate page), I am able to pass the parent ID with the URL like this:
versteckter Link;
However, even though it resolves correctly (to 75 in this case), on the new page it preselects "logo erfassen", what is the page title instead of the relationship. I assume there is something wrong with the URL generated.
Best,
Marcial
You can get the URL parameter "wpv-post-id" value with shortcode [wpv-search-term], for example:
[wpv-search-term param="wpv-post-id"]
versteckter Link
Then pass it to form shortcode [cred_field], like this:
[cred_field field="@RELATIONSHIP-SLUG.parent" value='[wpv-search-term param="wpv-post-id"]'class="form-control" output="bootstrap" select_text="--- not set ---"]
My issue is resolved now. Thank you!