Let's say I've got 'select' type field with options: 1, 2, 3.
I want to write it at content template like this (say 1 is selected value):
<tr>
<td>Field name:</td>
<td>[x] 1, [ ] 2, [ ] 3</td>
</tr>
I need it to send by mail for manual submission (or to print).
How would I do this?
One way to handle this is to write out all the options manually, then use Conditional HTML to show an "X" inside the selected option.
[ [wpv-conditional if="( $(wpcf-field) eq '1' )"]X[/wpv-conditional] ] 1
[ [wpv-conditional if="( $(wpcf-field) eq '2' )"]X[/wpv-conditional] ] 2
[ [wpv-conditional if="( $(wpcf-field) eq '3' )"]X[/wpv-conditional] ] 3
Replace "wpcf-field" with the slug of your custom field (prefixed by wpcf-), and replace '1', '2', and '3' in the conditional with the actual values of each option.
With a bit of custom code, you could probably automate this so you don't have to write out each option in a conditional. More information about conditional HTML can be found here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
Is there no API that will get me a list of options of the field? You get them internally obviously...
A custom SQL query could find all the unique values for this postmeta key, but unfortunately there is no public API available to get all the available options. Our documented APIs can be found here:
https://toolset.com/documentation/programmer-reference/
$fields = wpcf_admin_fields_get_active_fields_by_post_type('applications');
took me half an hour to find...
This is with multiple values support