Skip Navigation

[Resolved] I need to automatically assign a parent relationship value in a child form

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 1 voice.

Last updated by Minesh 6 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2787216

Tell us what you are trying to do?
I am trying to obtain the parent ID of the current post and have it automatically populated into a child form on the same page.
I have created the CPT "Tenders" which is the parent.
I want to allow users to submit "Tender queries" (which is the child CPT).
The single "Tender" view has a form for creating a new "Tender query" but I need the relationship to the parent to be automatically set when adding a new "Tender query"

Currently I have tried this code:
[cred_field field="@RELATIONSHIP-SLUG.parent" value='[wpv-search-term param="wpv-post-id"]' class="form-control" output="bootstrap" select_text="--- not set ---"]

Is there any documentation that you are following?
I tried https://toolset.com/forums/topic/parent-post-isnt-selected-automatically/#post-1136656

Is there a similar example that we can see?
I wasn't able to find one

What is the link to your site?
hidden link

Thanks in advance

#2787281

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What if you try to use the following code:

[cred_field field="@RELATIONSHIP-SLUG.parent" value='[wpv-post-id]' class="form-control" output="bootstrap" select_text="--- not set ---"]

Does that help you to resolve your issue?

#2787318

Hi Minesh. Thanks for your response and for your previous assistance.
Unfortunately this hasn't resolved my issue.
Could it be a permissions problem or something like that?

#2787423

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share problem URL where you added yoru form as well as admin access details and let me check whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2787601

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The issue was you do not replace the relationship slug.

You have added it as:

[cred_field field="@RELATIONSHIP-SLUG.parent" value='[wpv-post-id]' class="form-control" output="bootstrap" select_text="--- not set ---"]

So, I've replace the relationship slug as given under:

[cred_field field="@tender-to-tender-query.parent" value='[wpv-post-id]' class="form-control" output="bootstrap" select_text="--- not set ---"]

But as you are on the same parent page, it does not makes sense to add select dropdown, so I've added the generic hidden field that will hold the parent ID as given under:

[cred_generic_field type='hidden' field='@tender-to-tender-query.parent']
{
"default":"[wpv-post-id]"
}
[/cred_generic_field]
	

Now, when I submit a new item - it will automatically connected to its parent:
=> hidden link