I have a form element of "entity_autocomplete" type. Also I have an ajax callback of the element. Here is its code.
$form['autocomplete_places'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#selection_settings' => [
'target_bundles' => ['place'],
],
'#ajax' => [
'callback' => '::autocompleteGetPlaces',
'event' => 'autocompleteselect',
]
];
public function autocompleteGetPlaces(array &$form, FormStateInterface $form_state){
$ajax_responce = new AjaxResponse();
/// some code here
return $ajax_responce;
}
Unfortunately, I can't find out how to get the id of selected entity inside the ajax callback function. For example, in my case, it would be id of a node of "place" type.
I tried to debug it, but couldn't find information about it in $form_state.
Could you clarify me, how to do it ?