Linked Questions

2 votes
1 answer
8k views

Simple AJAX callback fired on form submission button click

I am trying to fire an AJAX callback when the user presses the submit button. This is such a simple thing but trying to debug Drupal's Form AJAX API is driving me crazy. At this point I just need a ...
iWig's user avatar
  • 51
-1 votes
1 answer
2k views

AJAX select returns 'illegal choice detected'

Create a settings form for a module in Drupal 8 - when a user selects a View from a list, the drop down under it should populate with the displays in that view. While the form updates the option list ...
Kevin's user avatar
  • 28k
2 votes
1 answer
5k views

Ajax Form submit doesn't work second time

I'm loading the node/edit form in a block and I add ajax on submit. I add the Ajax in the hook_form_alter. $form['#prefix'] = '<div id="' . $form_wrapper . '">'; $form['#suffix'] = '</div&...
Ismini's user avatar
  • 913
1 vote
1 answer
2k views

Drupal 8 Ajax Form Submit works only once?

I am trying to create a simple form in D8 that submits with a submit button and then replaces the entire form content via ajax. For some reason, my AJAX submit works perfectly on the first click but ...
Guardian's user avatar
  • 568
5 votes
1 answer
1k views

No Ajax gets initialised from inside the modal

I've got a bunch of forms that are opening inside a modal so that the user is not redirected off the page. I've then got a few Ajax calls on form items inside the form. They all work when using the ...
Mark A's user avatar
  • 51
3 votes
1 answer
2k views

8 - Ajax form not rebuild once submitted

I have an issue with a custom form in Drupal 8, using Ajax. Let me explain. I have two select fields, and when you choose an option in the first one, an Ajax request will get options for the second ...
Corentin Le Fur's user avatar
4 votes
1 answer
987 views

Prevent dual submit on form submission

I've got a form that submits via AJAX and in the callback I need to rebuild certain parts of the page to reflect the newly submitted data. One of these parts is the form, which I need to clear all ...
Lyndon Cox's user avatar
0 votes
1 answer
1k views

How do I check by default a checkbox from a checkboxes control after an AJAX call

I have the next form which behavior is: When you select an option from select control, different checkbox are load on checkboxes control. When you check/uncheck checkbox a message is showed on the ...
Javier Martín's user avatar
0 votes
1 answer
535 views

After an Ajax request that modifies the form it will not pass in the submitForm method

I have a form with 3 dropdowns. When changing the first one, it updates the 2 other by an ajax call. Once the 2 selects are re-rendered, when the user submits the form, it no longer pass in the ...
Guillaume Bois's user avatar
0 votes
0 answers
751 views

Ajax call with Submit loses submitted form data

I've built a super simple form in D8 meant to check the format of the field then when submitted the form data is placed in the DB. I check the format using a Ajax call -- yes, I know js is a better ...
Mike's user avatar
  • 597
0 votes
0 answers
726 views

Drupal8: tableselect form element. Drupal::service('renderer')->render($element) return empty rows

I have custom field widget with two fields: product_lines (checkboxes) sales_partners (tableselect) I need to ajax-reload sales_partners tablesect values depending on product_lines input In my ...
Artreaktor's user avatar
0 votes
1 answer
668 views

How can I give Ajax access to currently set fields on my form?

I'm working on a block form that needs to update certain elements in the form based on what the user selects with certain elements. I've defined the internal class method and it's getting called ...
Greenstack's user avatar
0 votes
0 answers
337 views

AJAX replaced elements not able to callback

I have a form with AJAX elements, generated as follows: $memberForm['members'] = [ '#prefix' => '<div id="'.$id.'">', '#suffix' => '</div>', ]; $form['...
James Shields's user avatar
0 votes
0 answers
80 views

Form field name not rendered after submit the form

I created a form and designed it by referred this link. It worked fine. I used the following code to display a textbox in my form public function buildForm(array $form, FormStateInterface $...
siddiq's user avatar
  • 363