Problem: I would like to include a generic checkboxes field in my CRED form. Each post in a CPT should be shown as a checkbox.
Solution:
Use this format to create a generic checkboxes field that uses a View to provide each option:
[cred_generic_field field='provider-checkboxes-slug' type='checkboxes' class='' urlparam=''] { "required":0, "validate_format":0, "default":[], "options":[ [wpv-view name='providers-checkboxes-options-view-slug'] ] } [/cred_generic_field]
Use this format in your View to generate the proper options format:
<wpv-loop> [wpv-item index=1] {"value":"[wpv-post-id]","label":"[wpv-post-title]"} [wpv-item index=other] ,{"value":"[wpv-post-id]","label":"[wpv-post-title]"} </wpv-loop>
Add the raw text output filter in PHP to clean up the output a bit further:
add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 ); function prefix_clean_view_output( $out, $id ) { if ( $id == '9999' ) { //Please adjust to your Views ID $start = strpos( $out, '<!-- wpv-loop-start -->' ); if ( $start !== false && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false ) { $start = $start + strlen( '<!-- wpv-loop-start -->' ); $out = substr( $out , $start ); $end = strrpos( $out, '<!-- wpv-loop-end -->' ); $out = substr( $out, 0, $end ); } } return $out; }
Replace 9999 with your View ID.
Relevant Documentation:
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
https://toolset.com/forums/topic/how-use-a-shortcode-instead-of-options-for-cred-forms
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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 11 replies, has 3 voices.
Last updated by 6 years, 11 months ago.
Assisted by: Christian Cox.