[Resolved] Prefill a select-field with a dynamic value
This thread is resolved. Here is a description of the problem and solution.
Problem:
Prefill a select-field with a dynamic value of parent field on CRED Toolset form
Solution:
[cred_field field='@fahrzeugbuchung-pkw.child' class='form-control' output='bootstrap' select_text='Wählen Sie das Auto aus, das Sie reservieren möchten' value='[wpv-post-id]']
This support ticket is created 6 years, 2 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I am trying to prefill a select-Field with the Value of the post title. I tried the following in the [cred_field]:
[cred_field field='@fahrzeugbuchung-pkw.child' class='form-control' output='bootstrap' select_text='Wählen Sie das Auto aus, das Sie reservieren möchten' value='[wpv-post-title]']
I expected to see: An Input-Field with the post-title as value.
Instead, I got: An empty select-Field (like in the screenshot 'Unbenannt.PNG').
When I use [wpv-post-title] I get the Output that I expect (example: PKW2). But it only doesn't work in the attribute 'value' of the shortcode.
I tried another possibility and passed the value as URL parameter. The Link I opened is the following:
<em><u>hidden link</u></em>
The Shortcode looks like this:
[cred_field field='@fahrzeugbuchung-pkw.child' class='form-control' output='bootstrap' select_text='--- nicht eingestellt ---' urlparam='fahrzeug']
Here i get the same result as in the screenshot (an empty input-field).
The cred_field field - value is a relation to another Post-Type (as you can see in the screenshot relation.PNG)
You can check the Versions of the installed toolset-plugins in the screenshot: versions.png
Hello. Thank you for contacting the Toolset support.
Well - all Toolset plugins installed on your site are latest one so there is no issue with that.
Can I have access details so I can look at your issue and check what's going wrong there and what could be the possible solution for you in your case?
Ahh - Are you using post-relationship form?
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Well - you need to pass the post ID using the shortcode [wpv-post-id] instead of [wpv-post-title].
So, form shortcode looks like as given under where it looks like value='[wpv-post-id]' :
<label>Ausgewähltes Auto</label>
[cred_field field='@fahrzeugbuchung-pkw.child' class='form-control' output='bootstrap' select_text='Wählen Sie das Auto aus, das Sie reservieren möchten' value='[wpv-post-id]']
And I see now the title is set as selected.
=> hidden link