Created
February 25, 2020 05:01
Star
You must be signed in to star a gist
GravityView - Display checkbox values as comma-separated instead of a bullet list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Convert checkbox <ul> to CSV values | |
* | |
* @param string $output The current output. | |
* @param \GV\Template_Context The template context this is being called from. | |
*/ | |
add_filter( 'gravityview/template/field/checkbox/output', function( $output, $context ) { | |
$value = $context->value; | |
// If a checkbox value is '' (empty string), this removes it. If you want empty strings, remove the line below. | |
$value = array_filter( $value, 'gravityview_is_not_empty_string' ); | |
return implode( ', ', $value ); | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment