public function AjaxFormBase::ajaxModalCallback in Forena Reports 8
Ajax callback.
_state
Parameters
$form:
Return value
\Drupal\Core\Ajax\AjaxResponse
1 call to AjaxFormBase::ajaxModalCallback()
- AjaxFormBase::submitCallback in src/
Form/ AjaxFormBase.php - Ajax callback handler for submit buttons.
File
- src/
Form/ AjaxFormBase.php, line 125
Class
- AjaxFormBase
- Class AjaxFormTrait
Namespace
Drupal\forena\FormCode
public function ajaxModalCallback(&$form, FormStateInterface $form_state) {
if ($form_state
->getErrors() || $form_state
->isRebuilding()) {
unset($form['#prefix']);
unset($form['#suffix']);
// array merge the status elements onto the beginning of the form
$ctl['status_messages'] = [
'#type' => 'status_messages',
'#weight' => -10,
];
$form = array_merge($ctl, $form);
$this->controller
->setEndCommand(new HtmlCommand('#e-modal-form', $form));
}
else {
// Process route when requested.
$this->controller->section = $this->controller->prior_section;
if (!$this->controller->prevent_action) {
$this->controller->post_form_id = $form_state
->getFormObject()
->getFormId();
$this->controller
->route($this->controller->action);
}
if (!$this->controller->modal_added) {
$this->controller
->addCommand(new CloseDialogCommand());
}
}
$commands = $this->controller
->getCommands();
$response = new AjaxResponse();
foreach ($commands as $command) {
$response
->addCommand($command);
}
$this->controller
->saveState();
return $response;
}