Anything I could find related to this question was for Drupal 7.
I am building a form that needs to perform a certain ajax function when a date is selected. I have built my form to work similarly to the "Form API Examples - Ajax Form Example" part of the Examples module.
To test, I set it up so that, like in the example, when this Select element is changed it triggers the function "dateCallback":
$form['dropdown'] = [
'#title' => $this->t('Test'),
'#type' => 'select',
'#options' => ['option1' => '1', 'option2' => '2'],
'#ajax' => [
'callback' => '::dateCallback',
'wrapper' => 'log-wrapper',
],
];
This executes perfectly.
However, when I try to set up a Date element to do the same function, nothing happens. No Ajax spinner, just nothing happens at all.
$form['date'] = array(
'#type' => 'date',
'#title' => t('Date'),
'#ajax' => [
'callback' => '::dateCallback',
'wrapper' => 'log-wrapper',
],
);
It does not work even if I include 'event' => 'onchange'
in the #ajax
array.
Is it possible to make ajax functions trigger on a changed date field?