protected function WebformAjaxFormTrait::createAjaxResponse in Webform 8.5
Same name and namespace in other branches
- 6.x src/Form/WebformAjaxFormTrait.php \Drupal\webform\Form\WebformAjaxFormTrait::createAjaxResponse()
Create an AjaxResponse or WebformAjaxResponse object.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\Core\Ajax\AjaxResponse An AjaxResponse or WebformAjaxResponse object
4 calls to WebformAjaxFormTrait::createAjaxResponse()
- WebformAjaxFormTrait::replaceForm in src/
Form/ WebformAjaxFormTrait.php - Replace form via an Ajax response.
- WebformAjaxFormTrait::submitAjaxForm in src/
Form/ WebformAjaxFormTrait.php - Submit form #ajax callback.
- WebformDialogFormTrait::cancelAjaxForm in src/
Form/ WebformDialogFormTrait.php - Cancel form #ajax callback.
- WebformEntityAjaxFormTrait::replaceForm in src/
Form/ WebformEntityAjaxFormTrait.php - Replace form via an Ajax response.
File
- src/
Form/ WebformAjaxFormTrait.php, line 308
Class
- WebformAjaxFormTrait
- Trait class for Webform Ajax support.
Namespace
Drupal\webform\FormCode
protected function createAjaxResponse(array $form, FormStateInterface $form_state) {
$form_object = $form_state
->getFormObject();
if ($form_object instanceof WebformSubmissionForm) {
/** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
$webform_submission = $form_object
->getEntity();
$response = new WebformSubmissionAjaxResponse();
$response
->setWebformSubmission($webform_submission);
return $response;
}
else {
return new AjaxResponse();
}
}