I’m adding dynamically created checkboxes simplified example below:
add_filter( 'gform_form_post_get_meta', 'add_checkboxes' );
function add_checkboxes($form) {
//Duplicate checkbox from another field
//Update the ID, page number, choices, and inputs
$new_field = GF_Fields::create(GFFormsModel::get_field($form, 1011));
$new_field->id = $new_id;
$new_field->pageNumber = $page_number;
$new_field->choices = $choices;
$new_field->inputs = $inputs;
//Add the new checkbox to the form
return $form;
}
The new object looks like this:
GF_Field_Checkbox Object
(
[_is_entry_detail:GF_Field:private] =>
[_context_properties:GF_Field:private] => Array
(
)
[_merge_tag_modifiers:GF_Field:private] => Array
(
)
[_supports_state_validation:protected] => 1
[type] => checkbox
[id] => 5002
[formId] => 2
[label] => The Field Label
[adminLabel] => The Admin Field Label
[isRequired] =>
[size] => large
[errorMessage] =>
[visibility] => visible
[choices] => Array
(
[0] => Array
(
[text] => Text
[value] => Value
)
[1] => Array
(
[text] => Text
[value] => Value
)
)
[validateState] => 1
[inputs] => Array
(
[0] => Array
(
[label] => Text
[id] => 5002.1
)
[1] => Array
(
[label] => Text
[id] => 5002.2
)
)
[description] =>
[allowsPrepopulate] =>
[inputMask] =>
[inputMaskValue] =>
[inputMaskIsCustom] =>
[maxLength] =>
[inputType] => checkbox
[labelPlacement] =>
[descriptionPlacement] =>
[subLabelPlacement] =>
[placeholder] =>
[cssClass] => css-class
[inputName] =>
[noDuplicates] =>
[defaultValue] =>
[enableAutocomplete] =>
[autocompleteAttribute] =>
[conditionalLogic] =>
[productField] =>
[layoutGridColumnSpan] => 12
[enableSelectAll] =>
[choiceLimit] =>
[enablePrice] =>
[enableEnhancedUI] => 0
[layoutGroupId] => e5bb1d3f
[multipleFiles] =>
[maxFiles] =>
[calculationFormula] =>
[calculationRounding] =>
[enableCalculation] =>
[disableQuantity] =>
[displayAllCategories] =>
[useRichTextEditor] =>
[my_la] => word
[pageNumber] => 5
[fields] =>
[selectAllText] => Select All
[displayOnly] =>
[errors] => Array
(
)
)
The checkboxes show on the correct page with the correct options. But when the form is submitted the selected options are not included in the entry. Anybody know what I’m missing here?
Edit: the selected checkbox options are included in the admin notification email.
Thanks.