I am creating a custom form where I have 2 fields.
- Taxonomy : select field having list of vocabularies.
- Terms : Autocomplete field having terms list.
When I start typing in terms field, the value of the term field is passed to the routing function. However I also need the value of the taxonomy field in routing function so that I can restrict the terms list.
Is there anyway that I can get the other field values in the routing function?
Here is my buildform function :
public function buildForm(array $form, FormStateInterface $form_state) {
$form['taxonomy'] = [
'#type' => 'select',
'#title' => $this->t('Select Taxonomy'),
'#options' => $taxonomies,
];
$form['taxonomy_terms'] = [
'#type' => 'textfield',
'#autocomplete_route_name' => 'unido_drupal_admin.get_taxonomies'
];
return $form;
}
Here is my routing function :
public function get_taxonomies(Request $request) {
// Here I need to get taxonomy field value to restrict the result.
$params = $request->query->all();
$result = \Drupal\taxonomy\Entity\Vocabulary::loadMultiple();
}
Thanks.