Title: Automatically exclude HTML block fields
Last modified: March 9, 2021

---

# Automatically exclude HTML block fields

 *  Resolved [markhewes](https://wordpress.org/support/users/markhewes/)
 * (@markhewes)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/automatically-exclude-html-block-fields/)
 * Hi,
 * Is there a way to automatically exclude fields that don’t have any user input?
   Specifically, I have many forms with multiple HTML blocks. When I export the 
   spreadsheet, each HTML block has its own column. I know I can edit the settings
   for each form to exclude those fields manually, but would love it if there was
   a way to exclude them automatically.
 * Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Doeke Norg](https://wordpress.org/support/users/doekenorg/)
 * (@doekenorg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/automatically-exclude-html-block-fields/#post-14155216)
 * Hi [@markhewes](https://wordpress.org/support/users/markhewes/),
 * Fields can be disabled by default. Sections are excluded by default when you 
   enable that setting on the main settings page.
 * I’ll try to provide a hook you can add to your `functions.php` which disables
   all `html` fields later today.
 *  Plugin Author [Doeke Norg](https://wordpress.org/support/users/doekenorg/)
 * (@doekenorg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/automatically-exclude-html-block-fields/#post-14157865)
 * This should help you out:
 *     ```
       // Handle HTML Blocks like section fields, and disable them if the setting is true.
       add_filter('gfexcel_transformer_fields', function ($fields) {
           if (!array_key_exists('html', $fields)) {
               $fields['html'] = 'GFExcel\Field\SectionField';
           }
   
           return $fields;
       });
       ```
   
 * Be sure you have the sections turned off (this is the default settings).
 * Hope this helps you out.
 *  Thread Starter [markhewes](https://wordpress.org/support/users/markhewes/)
 * (@markhewes)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/automatically-exclude-html-block-fields/#post-14158168)
 * Perfect! Thanks so much. Could I also adapt this to exclude other field types?
   Credit Card, for example?
 *  Plugin Author [Doeke Norg](https://wordpress.org/support/users/doekenorg/)
 * (@doekenorg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/automatically-exclude-html-block-fields/#post-14159844)
 * Yes this should be possible. in that case it would be:
 *     ```
       add_filter('gfexcel_transformer_fields', function ($fields) {
           if (!array_key_exists('html', $fields)) {
               $fields['html'] = 'GFExcel\Field\SectionField';
           }
           if (!array_key_exists('creditcard', $fields)) {
               $fields['creditcard'] = 'GFExcel\Field\SectionField';
           }
   
           return $fields;
       });
       ```
   
 * But repeating those lines for even more can be a bit annoying, so something like
   this would be even better:
 *     ```
       // Disable these field types if sections are invisible.
       add_filter('gfexcel_transformer_fields', function ($fields) {
           // add types to this array
           $disable_field_types = [
               'html',
               'creditcard',
           ];
   
           foreach ($disable_field_types as $type) {
               if (!array_key_exists($type, $fields)) {
                   $fields[$type] = 'GFExcel\Field\SectionField';
               }
           }
   
           return $fields;
       });
       ```
   
 * It is possible I’m updating these field types in the future, thats why I added
   the `array_key_exists` check. If I provide a specific field class of my own, 
   that will take precedence. But for now I have no such ideas 😉
 *  Thread Starter [markhewes](https://wordpress.org/support/users/markhewes/)
 * (@markhewes)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/automatically-exclude-html-block-fields/#post-14163397)
 * Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Automatically exclude HTML block fields’ is closed to new replies.

 * ![](https://ps.w.org/gf-entries-in-excel/assets/icon.svg?rev=3434379)
 * [GravityExport Lite for Gravity Forms](https://wordpress.org/plugins/gf-entries-in-excel/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gf-entries-in-excel/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gf-entries-in-excel/)
 * [Active Topics](https://wordpress.org/support/plugin/gf-entries-in-excel/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gf-entries-in-excel/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gf-entries-in-excel/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [markhewes](https://wordpress.org/support/users/markhewes/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/automatically-exclude-html-block-fields/#post-14163397)
 * Status: resolved