# Pre Populated Checkbox fields not showing in entries and mails \[RESVOLVED\]

**URL:** <https://community.gravityforms.com/t/pre-populated-checkbox-fields-not-showing-in-entries-and-mails-resvolved/11203>\
**Category:** Get Help\
**Tags:** dynamic-population\
**Created:** [November 17, 2021, 10:47am UTC](https://community.gravityforms.com/t/pre-populated-checkbox-fields-not-showing-in-entries-and-mails-resvolved/11203 "2021-11-17T10:47:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user5a6f9991efbdb3.0](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5a6f9991efbdb3.0/32/3980_2.png) [@user5a6f9991efbdb3.0](https://community.gravityforms.com/u/user5a6f9991efbdb3.0)\
**Post date:** [November 17, 2021, 10:47am UTC](https://community.gravityforms.com/t/pre-populated-checkbox-fields-not-showing-in-entries-and-mails-resvolved/11203/1 "2021-11-17T10:47:23Z")

</div>

Hi, I am populating several checkboxes with values from ACF fields. That works great. However, when the form is submitted all those fields are not saved in entries. Here is my code in functions.php

```auto
add_filter( 'gform_pre_render_3', 'populate_checkbox' );
add_filter( 'gform_pre_validation_3', 'populate_checkbox' );
add_filter( 'gform_pre_submission_filter_3', 'populate_checkbox' );
add_filter( 'gform_admin_pre_render_3', 'populate_checkbox' );
function populate_checkbox( $form ) {
 
    foreach( $form['fields'] as &$field ) {
        //NOTE: replace ids with checkbox field ids
        if ( $field->id != 3 && $field->id != 4 && $field->id != 5 ) {
            continue;
        }
    //get field object stuff from ACF
    if($field->id == 5) {
      // get Arbeitsbereiche
      $options = get_field_object('field_618532e1e099f');
    } elseif($field->id == 4) {
	  // get Fachbereiche
	  $options = get_field_object('field_6185332ae09a0');
    } else {
	  // get Qualifikation
      $options = get_field_object('field_61853633923f5');
    }
 
        $input_id = 1;
        foreach( $options['choices'] as $value => $label ) {
 
        //skipping index that are multiples of 10 (multiples of 10 create problems as the input IDs)
        if ( $input_id % 10 == 0 ) {
            $input_id++;
        }
 
        $choices[] = array( 'text' => $label, 'value' => $value );   
        $inputs[] = array( 'label' => $label, 'id' => "{$field_id}.{$input_id}" );
 
        $input_id++;
        }
         
      $field->choices = $choices;
      $field->inputs = $inputs;
 
    }
 
    return $form;
}

```

I suspect there is some issue with the IDs? The fields also do not show up in mails with {all\_fields}.

The checkbox HTML looks like that in the form:

```auto
<fieldset id="field_3_5" class="gfield gfield--width-full field_sublabel_below field_description_below gfield_visibility_visible">
	<legend class="gfield_label gfield_label_before_complex">Arbeitsbereiche</legend>
	<div class="ginput_container ginput_container_checkbox">
		<div class="gfield_checkbox" id="input_3_5">
			<div class="gchoice gchoice_3_5_1"> 
				<input class="gfield-choice-input" name="input_5.1" type="checkbox" value="Kaufmännische Abwicklung" id="choice_3_5_1"> 
				<label for="choice_3_5_1" id="label_3_5_1">Kaufmännische Abwicklung</label>
			</div>
			<div class="gchoice gchoice_3_5_2"> 
				<input class="gfield-choice-input" name="input_5.2" type="checkbox" value="Technische Abwicklung" id="choice_3_5_2"> 
				<label for="choice_3_5_2" id="label_3_5_2">Technische Abwicklung</label>
			</div>
			<div class="gchoice gchoice_3_5_3"> 
				<input class="gfield-choice-input" name="input_5.3" type="checkbox" value="Außendienst" id="choice_3_5_3"> 
				<label for="choice_3_5_3" id="label_3_5_3">Außendienst</label>
			</div>
			<div class="gchoice gchoice_3_5_4"> 
				<input class="gfield-choice-input" name="input_5.4" type="checkbox" value="Produktion/Logistik" id="choice_3_5_4"> 
				<label for="choice_3_5_4" id="label_3_5_4">Produktion/Logistik</label>
			</div>
		</div>
	</div>
</fieldset>

```

I would be happy if anybody had an idea what is going wrong here 😉

Thanks Sascha

---

<div class="post-metadata">

**Author:** ![sacom](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/sacom/32/53_2.png) [@sacom](https://community.gravityforms.com/u/sacom)\
**Post date:** [November 18, 2021, 1:52pm UTC](https://community.gravityforms.com/t/pre-populated-checkbox-fields-not-showing-in-entries-and-mails-resvolved/11203/2 "2021-11-18T13:52:19Z")

</div>

Sascha, the snippet looks fine to me, it’s pretty much the example from the documentation but changing the source of the data.

I would recommend you to make sure your page is not being cached, as caching would prevent the dynamic population code from working.

You can also enable logging on the **Forms \> Settings** page and then on the **Forms \> Settings \> Logging** page ensure that Gravity Forms Core and any add-ons are enabled and set to log all messages.

> **[Logging and Debugging](https://docs.gravityforms.com/logging-and-debugging/)**
>
> For quite a while, enabling logging within Gravity Forms has been a go-to method for debugging any issues within Gravity Forms. As of Gravity Forms version 2.2, logging functionality has been moved from a separate add-on to becoming a core feature of...

Then you can add custom logging statements to your code to ensure it’s running when expected and **dump information in key parts of your code** to investigate what could be the issue, check instructions here: [https://docs.gravityforms.com/custom-logging-statements/#writing-to-the-core-log](https://docs.gravityforms.com/custom-logging-statements/#writing-to-the-core-log)

---

<div class="post-metadata">

**Author:** ![user5a6f9991efbdb3.0](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5a6f9991efbdb3.0/32/3980_2.png) [@user5a6f9991efbdb3.0](https://community.gravityforms.com/u/user5a6f9991efbdb3.0)\
**Post date:** [November 18, 2021, 2:30pm UTC](https://community.gravityforms.com/t/pre-populated-checkbox-fields-not-showing-in-entries-and-mails-resvolved/11203/3 "2021-11-18T14:30:20Z")

</div>

My bad. There was a $field\_id where it should have been $field-\>id

Works well now 😉

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [November 18, 2021, 5:00pm UTC](https://community.gravityforms.com/t/pre-populated-checkbox-fields-not-showing-in-entries-and-mails-resvolved/11203/4 "2021-11-18T17:00:18Z")

</div>


