fholub13 β created an issue.
fholub13 β created an issue.
fholub13 β created an issue.
Ran into a similar issue with AJAX wherein there were two custom forms on a page, provided by separate custom modules. One is in the site header as a custom search block and the second as a form class that serves as the content for a custom route. An AJAX handler defined for the second form submit
element was binding to the submit
element of the first form. Both elements had the default id of #edit-submit
.
This issue only occurs for anonymous users. The AJAX handler actually binds correctly given the following is true:
- Cache was cleared.
- The first page visited after the cache clear was the custom form route.
After identifying this behavior, the workaround we devised for this particular instance was to modify the submit element of the first form to have custom id and data-drupal-selector attributes while leaving the second form as-is.
Before
$form['container']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Search'),
];
After
$form['container']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Search'),
'#attributes' => [
'id' => 'edit-submit-prod-num',
'data-drupal-selector' => 'edit-submit-prod-num',
],
];
#10 worked for me as described.
#5 was my exact experience as well. I had the aforementioned former patch installed (3316975-15) on a client site and was experiencing the error detailed in this issue. Removing the patch, deleting the module directory, and running a new composer install remedied the error.