ajax on button throw exception The specified #ajax callback is empty or not callable


Change your callbacks to be like this:

'callback' => [$this, 'catSelectedCallback'],

Not totally sure but I think that the problem is that both buttons (addTermsBtn and addFieldsBtn) have the same #value. Try to use different #value for the buttons or use #name attribute for differentiate them.

Tags: Forms / Drupal 8 / Ajax

Similar questions

Drupal Custom Module: How to Throw error When User Not select Checked box
I am developing a Drupal module. I have a file type to upload PDFs and a checked box that must be checked when user uploads a PDF, and if the user uploads a PDF but has not checked the check box an error is thrown and it goes back to the 'add content' form and highlights the check box. I have hooked hook_nodeapi() to check whether checkbox is check...
Form ajax add more button added via another ajax callback not working
I have a form button which I want to add another field with another button on that form( I am able to do this) but second button is not clickable. Any idea. Following is my code- This is my form code- Now, when I click on this button it will call the following function and generate another form element(select list) with another button which will ca...
Custom submit button callback overrides default callback?
I am trying to accomplish the following functionality: I have a profile2 registration form to which I have added a custom form element (just a submit button) using hook_form_alter(). The submit button has a #submit property set to a custom_callback function. For debugging purposes, the callback function just displays a The general idea is that the ...
Exception in worker callback prevents queue item from being removed
I have created a Drupal 7 module that utilizes hook_cron() and hook_cron_queue_info() to process some data, as well as use the module Ultimate Cron to handle scheduling when each runs. hook_cron() is run every 15 minutes and it's job is to determine how much data needs to be processed and split it up into batches, creating a queue for each batch. A...
Form field not show on Ajax Callback even the callback is called
I have a form with one shown field of type select with ajax callback to show another form field dynamically of type select and with ajax callback again, the problem is second field ajax callback should show a third field dynamically but nothing is shown. here is my code
How to remove empty div created by routing.yml file by specified routes?
I have 2 routes Route games.one has _title and Route games.two does not have. Now the issue is When I access route game.two, It shows an empty div for title. How to remove this empty div?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.