'etiquettes', 'hide_empty' => false, // Include empty terms )); // Prepare choices array for the select field $choices = array(); foreach ($terms as $term) { $choices[] = array( 'text' => $term->name, 'value' => $term->term_id, ); } // Find the select field by ID foreach ($form['fields'] as &$field) { if ($field->id == $field_id) { // Update choices for the select field $field->choices = $choices; break; } } } return $form; }