Tell us what you are trying to do?
Preselect parent in childpost form
I have done many searches of the documentation, but most results are very old, and many of the solutions seem to be hidden in the support threads.
What is the link to your site?
hidden link
I've created a CRED form to add new child posts to a CPT parent. This form will display ON the parent CPT page (and maybe in a View loop).
I have a relationship field that was inserted via the relationship field in the Form Wizard.
This generated the following code in the form:
<label for="%%FORM_ID%%_@competition-entry-competition-entry-rating.parent">[cred_i18n name='@competition-entry-competition-entry-rating.parent-label']Competition Entry[/cred_i18n]</label>
[cred_field field='@competition-entry-competition-entry-rating.parent' class='form-control' output='bootstrap' select_text='--- not set ---' required='true' author='$current' urlparam='parent_competition-entry_id']
(I've switched to the advanced form editor, and don't think I can switch back to the wizard without losing manual changes I've made). I tried doing this manually in a hidden field, but was not successful.
The above wizard code generates a drop-down select that works fine for creating the child post relationship, but I just need to have this field value pre-selected (and hidden - I know I can hide it with CSS).
It would seem that it should be easy to change this select to a single (hidden) field, but I'm not seeing how to do it.
Hello,
Please try to replace the shortcode you mentioned above from:
[cred_field field='@competition-entry-competition-entry-rating.parent' class='form-control' output='bootstrap' select_text='--- not set ---' required='true' author='$current' urlparam='parent_competition-entry_id']
To:
[cred_field field='@competition-entry-competition-entry-rating.parent' class='form-control' output='bootstrap' select_text='--- not set ---' required='true' author='$current' urlparam='parent_competition-entry_id' value='[wpv-post-id item="$current_page"]']
and test again
More help:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field
value. Optional. Preset value
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
$current_page is used to retrieve data from the current page being rendered.
Thanks Luo. That works perfectly.