When select is changed drupal generate error - Symfony\Component\HttpKernel\Exception\HttpException: The specified #ajax callback is empty or not callable. in Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse() (line 67 of E:\xampp\htdocs\m827\core\lib\Drupal\Core\Form\FormAjaxResponseBuilder.php).
When #tree is false its work perfectly, and when I turned on #tree to TRUE, it gives error of empty callback, I have checked the in FormAjaxResponseBuilder.php found out when change in select element, in triggringElement it returns the submit(filter_search) element.
One more thing when I used uniqid() in $rowId, it gives empty callback error, but if I provide hardcoded value in the $rowId, it worked perfectly.
public function buildForm(array $form, FormStateInterface $form_state) {
$form['tool-container'] = array(
'#type' => 'container',
'#prefix' => '<div id="tool-container-main">',
'#suffix' => '</div>',
'#tree' => TRUE,
);
$rowId = uniqid();
//$rowId = 'fghfg567df';
$form['tool-container'][$rowId] = [
'#type' => 'container',
];
$form['tool-container'][$rowId]['tools'] = [
'#type' => 'select',
'#title' => t('Tools selected'),
'#empty_option' => '-Select-',
'#options' => [1=>1,2=>2,3=>3],
'#required' => TRUE,
'#ajax' => [
'callback' => '::updateTframeCostPrice',
'wrapper' => 'tool-container-main',
'effect' => 'fade',
'event' => 'change',
'progress' => array('type'=> 'throbber', 'message'=> NULL),
],
];
$form['filters-submit'] = [
'#type' => 'submit',
'#name' => 'filter_search',
'#value' => $this->t('Search'),
'#limit_validation_errors' => array(),
];
return $form;
}