Skip Navigation

[Resolved] Relationship form

This thread is resolved. Here is a description of the problem and solution.

Problem:

In a form for creating child post, need to setup the default value of relationship field as current parent post.

Solution:

You just need to setup the default value of relationship field as current "accommodation" post ID, see details here:

https://toolset.com/forums/topic/relationship-form/#post-1123516

Relevant Documentation:

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by domenicoS 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1122664

Hi,

I've a relationship between:

- "Accommodation" post type
- "Quote" post type

I've created a form to add a new post type "Quote"

This form is displayed in an "Accommodation" post type

When this form is submitted should be direclty update a relationship between the "accommodation" where the post is displyed and the new "Quote" post type created with the form.

#1123361

Hello,

I suggest you setup one-to-many relationship between those post types:
- "Accommodation" post type
- "Quote" post type

Then you will be able to create a post form for creating "Quote" post, it will be able to related the new "Quote" post with specific "Accommodation" post, see our document:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

Section "Creating forms when a parent post is preselected"

#1123428

Hi Luo, is not what I'me searching for.

I've just create a post to add a new "quote" post type and i've also just created a relationship one-to-many.

What I need is to does not choose the "Accommodation" post type to associate to the "Quote post type" but assingn it automatically.

The form to add a new "Quote" is displayed in the "Accommodation" post will be related.

So how to set automatically a relation between the new post I'm creating the the second post where i displayed?

If you share me private messagge I shoe you the link, could be more clear.

#1123437

OK, I have enabled the private message box, please provide the your website credentials and the links, thanks

#1123516

Thanks for the detail, you just need to setup the default value of relationship field as current "accommodation" post ID, for example, modify the shortcode from:

[cred_field field="@preventivo-struttura.parent" class="form-control" output="bootstrap" select_text="--- non impostato ---" readonly='false']

To:
[cred_field field="@preventivo-struttura.parent" class="form-control" output="bootstrap" select_text="--- non impostato ---" readonly='false' value="[wpv-post-id]"]

Then test again, and you can use CSS codes to hide the relationship field.

More help:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
value. Optional. Preset value

#1123533

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.