public function LayouterForm::cancelForm in Layouter - WYSIWYG layout templates 8
Form submit handler triggered by 'cancel' button. Closes popup form.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: Form state.
File
- src/
Form/ LayouterForm.php, line 179
Class
- LayouterForm
- Provides multistep ajax form for an layout choice.
Namespace
Drupal\layouter\FormCode
public function cancelForm(array &$form, FormStateInterface $form_state) {
// Delete loaded files.
if ($form_state
->hasFileElement()) {
foreach ($form_state
->get('fields') as $name => $params) {
if ($params['type'] == 'image') {
$input = $form_state
->getUserInput();
if (!empty($input[$name]['fids'])) {
File::load($input[$name]['fids'])
->delete();
}
}
}
}
$response = new AjaxResponse();
$response
->addCommand(new CloseModalDialogCommand());
$form_state
->setResponse($response);
}