Skip Navigation

[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]']

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/prefill-a-select-field-with-a-dynamic-value/#post-1109423

Relevant Documentation:

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

Last updated by klausB 6 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1109351
relation.PNG
versions.PNG
Unbenannt.PNG

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

#1109409

Minesh
Supporter

Languages: English (English )

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

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.

#1109423

Minesh
Supporter

Languages: English (English )

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

Ok.

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

#1109424

Thats it. Thank you !