Skip Navigation

[Resolved] Set relationship field default value to current post

This support ticket is created 2 years, 3 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
- 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 4 replies, has 2 voices.

Last updated by jamesR-13 2 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2233529

I am displaying a form for a post inside the content template for its parent post. How do I set the default value of the relationship field to be the current (parent) post?

#2233715

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

With your parent relationship field's value attribute what if you pass the value $current and check if that works for you.

For example:

[cred_field field='@employee-post.parent' class='form-control' output='bootstrap' value="$current" select_text='--- not set ---' required='false']

As you can see how the value attribute is populated with $current:

value="$current"
#2234251

My issue is resolved now. Thank you!

#2234319

OK, so that does populate the field, but when the form is submitted, the relationship isn't created between the two posts.

I can give access to the site if you will turn on the private fields, please.

#2234579

My issue is resolved now. Thank you!

Replaced $current with [wpv-post-id] and it is working now.

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