Problem: When I use a View to output options for a generic select field, the select field disappears. If I copy the same output generated by the View and paste it as the value of "options" in my CRED form, the select field appears as normal.
Solution: Use a filter to strip out extra characters from your View's output that may be breaking the JSON structure of your options. Add the following code in your functions.php file:
add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
function prefix_clean_view_output( $out, $id ) {
if ( $id == '999' ) { //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;
}
Be sure to replace the $id variable with your View's ID.
Relevant Documentation: N/A