Skip Navigation

[Escalated to 2nd Tier] Set value in cred-relationship-field

This support ticket is created 5 years, 8 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/Karachi (GMT+05:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 5 years, 8 months ago.

Assisted by: Waqar.

Author
Posts
#1233579

I have two CPTs (A and B)
These CPTs have a relationship (A/B) with custom field named “status”.
I have a relationship form to create relation post (A/B).
I need to set value “1" for field “status” in this relationship form.

Don’t work when i use:
[cred-relationship-field name="status” value=“1"]

How setting the value in cred-relationship-field?

#1233838

Hi there,

Thanks for asking! I'd be happy to help.

Currently, the "cred-relationship-field" shortcode only accepts the "name" attribute, as mentioned in the documentation:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred-relationship-field

To include the support for the default value attribute too, you're welcome to submit this as a feature request at:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

I noticed that the interface to add the "cred-relationship-field" shortcode offers fields to add the default and URL parameter value when they both aren't supported. I've shared this to the concerned team for further review and will keep you updated with the progress through this ticket.

Meanwhile, to add a default value to that field, you can add some custom script in the form's "JS editor" tab.

For example:


jQuery(document).ready(function() {
    jQuery('input[name="wpcf[field-slug]"]').val('1');
});

Note: Please replace "field-slug" with the actual slug of your field and the 1 with the value that you'd like to fill.

regards,
Waqar