I am generating a multiselect field based on subcategories.
add_filter('gform_pre_render_1', 'amenities');
function amenities($form){
$amenities = get_categories(array('child_of' => 15, 'order_by' => 'name', 'hide_empty' => 0));
$amenities_choices = array();
foreach ($amenities as $amenity) {
$amenities_choices[] = array('text' => $amenity->name, 'value' => $amenity->term_id);
}
foreach($form['fields'] as &$field) {
if($field['id'] == 12) {
$field['choices'] = $amenities_choices;
}
}
return $form;
}
This works great. The problem is that on the creation of the form, I only have one "item" on the multiselect. So when processing Gforms only checks for one. I am looking for something that can be adjusted via a filter so it will process numbers based on the newly generated multiselect options.