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?
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