The gform_entry_detail_grid_display_empty_fields filter allows you to display empty fields on the entry detail page or print view, even if the option is not checked.
Usage
add_filter('gform_entry_detail_grid_display_empty_fields', 'your_function_name');
Parameters
- $display_empty_fields (bool): Determines whether empty fields should be displayed.
- $form (Form Object): The form object the entry currently being viewed belongs to.
- $entry (Entry Object): The entry currently being viewed.
More information
See Gravity Forms Docs: gform_entry_detail_grid_display_empty_fields
Examples
Force display of empty fields
Display empty fields on the entry detail page or print view regardless of the option status.
add_filter('gform_entry_detail_grid_display_empty_fields', '__return_true');
Use the cookie set by the “show empty fields” checkbox
Include empty fields in the entry printout based on the cookie value set by the “show empty fields” checkbox.
add_filter('gform_entry_detail_grid_display_empty_fields', function($display_empty_fields) { if (!$display_empty_fields) { $display_empty_fields = rgget('gf_display_empty_fields', $_COOKIE); } return $display_empty_fields; });
Display empty fields for a specific form
Display empty fields only for a specific form with form ID 5.
add_filter('gform_entry_detail_grid_display_empty_fields', function($display_empty_fields, $form, $entry) { if ($form['id'] == 5) { return true; } return $display_empty_fields; }, 10, 3);
Display empty fields based on user role
Display empty fields only for users with the ‘editor’ role.
add_filter('gform_entry_detail_grid_display_empty_fields', function($display_empty_fields) { if (current_user_can('editor')) { return true; } return $display_empty_fields; });
Display empty fields for specific field types
Display empty fields only for specific field types, such as checkboxes and radio buttons.
add_filter('gform_entry_detail_grid_display_empty_fields', function($display_empty_fields, $form, $entry) { foreach ($form['fields'] as $field) { if (in_array($field->type, array('checkbox', 'radio'))) { return true; } } return $display_empty_fields; }, 10, 3);