Skip Navigation

[Resolved] Default value for generic field on edit CRED form

This support ticket is created 4 years 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.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by julieP 4 years ago.

Author
Posts
#1833385

I'm using a generic field on an edit form. How do I set the dropdown to display the current value for the post please? In my tests, the current value for the post is 11.15 but the edit form displays 09.00 (the first value in the list). I've tried it numerous ways using the types shortcode and a custom shortcode but it's not working. Here's my generic field code:-

[cred_generic_field type='select' field='wpcf-action-time']
{
"required":1,
"default":"",
"persist":1,
"options":[
{"value":"09.00","label":"09.00"},
{"value":"09.15","label":"09.15"},
{"value":"09.30","label":"09.30"},
{"value":"09.45","label":"09.45"},
{"value":"10.00","label":"10.00"},
{"value":"10.15","label":"10.15"},
{"value":"10.30","label":"10.30"},
{"value":"10.45","label":"10.45"},
{"value":"11.00","label":"11.00"},
{"value":"11.15","label":"11.15"},
{"value":"11.30","label":"11.30"},
{"value":"11.45","label":"11.45"},
{"value":"12.00","label":"12.00"}
]
}
[/cred_generic_field]

Many thanks

#1834071

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You have a default option (currently empty in your example).

I just made a custom shortcode [default] that simply returns "2" and then was able to set the second option as the default like so:

[cred_generic_field type='select' field='selection']
{
"required":0,
"default":"[default]",
"options":[{"value":"1","label":"One"},{"value":"2","label":"Two"},{"value":"3","label":"Three"}]
}
[/cred_generic_field]

I'm not sure what you are using to try and set the default, but in principle there is no reason you cannot set the default via a shortcode.

#1835585

Not sure what happened but when I visited the page later on, the value from the post was showing (as expected/required). I'll monitor it and re-visit if I need to.