---
title: "Checkbox values for removed choices are missing from exports"
date: 2026-07-09
author: "Rafael Bennemann"
link: "https://www.gravitykit.com/docs/gravityexport/checkbox-removed-choices-missing-from-exports/"
---

When entries are exported with GravityExport or GravityExport Lite, checkbox values are read from the field's current list of choices. If a choice is removed from the field after entries were submitted, the values stored under that choice no longer appear in exports. The submitted data itself is untouched and remains in the database. Adding new choices never causes this, only removing them does.

## Why this happens

Gravity Forms links each stored checkbox selection to a specific choice on the field. Exports read values for the field's current choices only, so when a choice is removed, the entries that selected it no longer have a matching choice and their values are skipped. Gravity Forms' own entry export works the same way, so this is platform behavior rather than a GravityExport setting.

## Restoring the missing values

### Option 1: Re-add the removed choices

Re-add the removed choices to the field in their original positions. Their stored values immediately return to the export, exactly as they were submitted. For a one-time export, you can re-add the choices, run the export, and then remove them again.

### Option 2: Use a code snippet

The snippet below replaces the checkbox export handler with one that also reads values stored under choices that no longer exist on the field. It covers GravityExport Lite, GravityExport, and the multi-row extension. Exports for fields whose choices are intact are not affected.

```
/**
 * GravityExport / GravityExport Lite: include checkbox values stored under
 * choices that were later removed from the field.
 *
 * Exports read values for a checkbox field's current choices only, so
 * values submitted for a since-removed choice are skipped. This registers
 * a replacement export handler that reads those values as well.
 *
 * GravityExport instantiates the handler per field from a class name, so
 * the handler has to be a class; it is defined inside the callback so it
 * only exists once GravityExport Lite is active.
 */
add_action( 'plugins_loaded', function () {
    // Bail if GravityExport Lite is not active, or the snippet was already loaded.
    if ( ! class_exists( 'GFExcel\Field\CheckboxField' ) || class_exists( 'GK_CheckboxAllMetaField' ) ) {
        return;
    }

    class GK_CheckboxAllMetaField extends \GFExcel\Field\CheckboxField {
        public function getRows( ?array $entry = null ): iterable {
            $inputs = $this->field->get_entry_inputs();

            // Fields without per-choice inputs keep the default behavior.
            if ( ! is_array( $inputs ) ) {
                yield from parent::getRows( $entry );
                return;
            }

            // Start from the keys of the field's current choices.
            $keys = array_map( static function ( $input ) {
                return (string) $input['id'];
            }, $inputs );

            // Add every stored key for this field, including removed choices.
            // Example: the entry still holds 17.3 while the field now stops at 17.2.
            foreach ( array_keys( (array) $entry ) as $key ) {
                if ( preg_match( '/^' . preg_quote( (string) $this->field->id, '/' ) . '\.\d+$/', (string) $key ) ) {
                    $keys[] = (string) $key;
                }
            }

            // Keep the exported values in choice order.
            $keys = array_unique( $keys );
            usort( $keys, static function ( $a, $b ) {
                return (int) substr( $a, strpos( $a, '.' ) + 1 )  (int) substr( $b, strpos( $b, '.' ) + 1 );
            } );

            // Read each stored value the same way the default handler does.
            $has_values = false;
            foreach ( $keys as $index ) {
                if ( ! rgempty( $index, $entry ) ) {
                    $has_values = true;
                    $value      = $this->filter_value( $this->getFieldValue( $entry, $index ), $entry );
                    yield $this->wrap( [ $value ] );
                }
            }

            // Preserve the default placeholder behavior for entries with no values.
            if ( ! $has_values ) {
                $empty_value = gf_apply_filters(
                    [ 'gfexcel_field_checkbox_empty', $this->field->formId, $this->field->id ],
                    '',
                    $entry,
                    $this->field
                );

                if ( '' !== $empty_value ) {
                    yield $this->wrap( [ $empty_value ] );
                }
            }
        }
    }

    // Tell GravityExport to use the handler above for checkbox fields.
    add_filter( 'gfexcel_transformer_fields', function ( array $fields ): array {
        $fields['checkbox'] = 'GK_CheckboxAllMetaField';
        return $fields;
    } );
} );
```

```
/**
 * GravityExport / GravityExport Lite: include checkbox values stored under
 * choices that were later removed from the field.
 *
 * Exports read values for a checkbox field's current choices only, so
 * values submitted for a since-removed choice are skipped. This registers
 * a replacement export handler that reads those values as well.
 *
 * GravityExport instantiates the handler per field from a class name, so
 * the handler has to be a class; it is defined inside the callback so it
 * only exists once GravityExport Lite is active.
 */
add_action( 'plugins_loaded', function () {
    // Bail if GravityExport Lite is not active, or the snippet was already loaded.
    if ( ! class_exists( 'GFExcel\Field\CheckboxField' ) || class_exists( 'GK_CheckboxAllMetaField' ) ) {
        return;
    }

    class GK_CheckboxAllMetaField extends \GFExcel\Field\CheckboxField {
        public function getRows( ?array $entry = null ): iterable {
            $inputs = $this->field->get_entry_inputs();

            // Fields without per-choice inputs keep the default behavior.
            if ( ! is_array( $inputs ) ) {
                yield from parent::getRows( $entry );
                return;
            }

            // Start from the keys of the field's current choices.
            $keys = array_map( static function ( $input ) {
                return (string) $input['id'];
            }, $inputs );

            // Add every stored key for this field, including removed choices.
            // Example: the entry still holds 17.3 while the field now stops at 17.2.
            foreach ( array_keys( (array) $entry ) as $key ) {
                if ( preg_match( '/^' . preg_quote( (string) $this->field->id, '/' ) . '\.\d+$/', (string) $key ) ) {
                    $keys[] = (string) $key;
                }
            }

            // Keep the exported values in choice order.
            $keys = array_unique( $keys );
            usort( $keys, static function ( $a, $b ) {
                return (int) substr( $a, strpos( $a, '.' ) + 1 )  (int) substr( $b, strpos( $b, '.' ) + 1 );
            } );

            // Read each stored value the same way the default handler does.
            $has_values = false;
            foreach ( $keys as $index ) {
                if ( ! rgempty( $index, $entry ) ) {
                    $has_values = true;
                    $value      = $this->filter_value( $this->getFieldValue( $entry, $index ), $entry );
                    yield $this->wrap( [ $value ] );
                }
            }

            // Preserve the default placeholder behavior for entries with no values.
            if ( ! $has_values ) {
                $empty_value = gf_apply_filters(
                    [ 'gfexcel_field_checkbox_empty', $this->field->formId, $this->field->id ],
                    '',
                    $entry,
                    $this->field
                );

                if ( '' !== $empty_value ) {
                    yield $this->wrap( [ $empty_value ] );
                }
            }
        }
    }

    // Tell GravityExport to use the handler above for checkbox fields.
    add_filter( 'gfexcel_transformer_fields', function ( array $fields ): array {
        $fields['checkbox'] = 'GK_CheckboxAllMetaField';
        return $fields;
    } );
} );
```

Read here how to add these code samples to your website: [Where to put code samples.](https://www.gravitykit.com/docs/gravityview/customizing-your-views/where-to-put-code-samples/)