Problem/Motivation + steps to reproduce
In my signup form, I've moved the `$form['actions']` element to a wrapper so the structure is now: `$form['container']['actions']`.
This breaks the ajax submit functionality, because in the ajax submit, the following happens:
public function ajaxSubmit(array $form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response_wrapper_id = '#' . $form['actions']['submit']['#ajax']['response_wrapper'];
...
}Proposed resolution
Due to it being bad practice to call the element directly in any case, I propose we replace it with this instead:
public function ajaxSubmit(array $form, FormStateInterface $form_state) {
$triggering_element = $form_state->getTriggeringElement();
$response = new AjaxResponse();
$response_wrapper_id = '#' . $triggering_element['#ajax']['response_wrapper'];
...
}Then it doesn't matter where the actions element is located, since the button should always be the triggering element.
Remaining tasks
Test MR.
Issue fork mailchimp-3400501
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
randalv commentedMR 's been updated, although I don't see the changes come through yet here in the issue itself.
Comment #3
randalv commentedComment #9
xenophyle commentedThanks!