-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
Summary
Add a field setting to enable CSV (comma-separated) display mode for checkbox fields, eliminating the need for users to manually add custom code via filters.
Current Situation
Currently, users who want to display checkbox field values as comma-separated text instead of the default bulleted list must add custom code to their theme's functions.php file or create a custom plugin using the gravityview/template/field/checkbox/output filter.
Current workaround requires:
add_filter( 'gravityview/template/field/checkbox/output', function( $output, $context ) {
$value = $context->value;
if ( is_array( $value ) ) {
// Convert array to comma-separated string
$value = array_filter( $value, function( $item ) {
return '' !== $item;
});
$output = implode( ', ', $value );
}
return $output;
}, 10, 2 );Proposed Solution
Add a new field setting option to the checkbox field configuration that allows users to choose between:
- Default - Current bulleted list display
- CSV - Comma-separated values display
Implementation Details
Field Setting Addition
- Add new radio button option to the checkbox field settings in the "Display" group
- Similar to existing
choice_displaysetting pattern - Should be available for the parent checkbox field (not individual inputs)
Setting Configuration
$field_options['display_format'] = array(
'type' => 'radio',
'class' => 'vertical',
'label' => __( 'Display Format:', 'gk-gravityview' ),
'value' => 'default',
'choices' => array(
'default' => __( 'Bulleted list (default)', 'gk-gravityview' ),
'csv' => __( 'Comma-separated values', 'gk-gravityview' ),
),
'group' => 'display',
'priority' => 110,
);Template Logic Update
Update templates/fields/field-checkbox-html.php to check for the new setting and apply CSV formatting when selected.
Technical Requirements
Files to Modify
includes/fields/class-gravityview-field-checkbox.php- Add field settingtemplates/fields/field-checkbox-html.php- Add display logic
Backward Compatibility
- Default behavior remains unchanged (bulleted list)
- Existing custom filter implementations continue to work
- New setting only affects display when explicitly selected
User Experience
- Setting should only appear for parent checkbox fields (not individual checkbox inputs)
- Clear labeling to indicate the difference between display formats
- Should work with existing
choice_displaysetting combinations
Benefits
- User-Friendly - No code required, accessible through admin interface
- Backward Compatible - Doesn't affect existing implementations
- Consistent - Follows existing field setting patterns in GravityView
- Maintainable - Built into core functionality rather than requiring custom code
Acceptance Criteria
- New field setting appears in checkbox field configuration
- Setting only shows for parent checkbox fields (not individual inputs)
- CSV option displays values as comma-separated text
- Default option maintains current bulleted list behavior
- Works with all existing
choice_displayoptions (value, label, tick) - Backward compatibility maintained
- Setting follows existing UI patterns and styling
Related Documentation
- Current checkbox CSV workaround documentation
- Existing field setting patterns in
class-gravityview-field-checkbox.php
Metadata
Metadata
Assignees
Labels
No labels