public function FileDeleteForm::submitForm in Ubercart 8.4
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- uc_file/
src/ Form/ FileDeleteForm.php, line 119
Class
- FileDeleteForm
- Performs delete file action.
Namespace
Drupal\uc_file\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// File deletion status.
$status = TRUE;
// Delete the selected file(s), with recursion if selected.
$status = uc_file_remove_by_id($form_state
->getValue('file_ids'), !$form_state
->isValueEmpty('recurse_directories')) && $status;
if ($status) {
$this
->messenger()
->addMessage($this
->t('The selected file(s) have been deleted.'));
}
else {
$this
->messenger()
->addWarning($this
->t('One or more files could not be deleted.'));
}
$form_state
->setRedirectUrl($this
->getCancelUrl());
}