Score:1

Send an AJAX response and rebuild a form in a single AJAX callback

us flag

I need to execute multiple AJAXCommands and rebuild form in one AJAXCallback function, but the documentation says the AJAXCallback function should return AjaxResponse OR FormElement.

Using ReplaceCommand to replace an element is difficult because after the AjaxCallback SubmitButton should be searched, and its #Submit function.

How can I do this?

Jaypan avatar
de flag
Here's a tutorial I wrote on doing ajax in the Form API correctly: https://www.jaypan.com/tutorial/drupal-form-api-ajax-form-and-results-same-page
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.