public function ShowForm::validateForm in Ubercart 8.4
Form validation 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 FormBase::validateForm
File
- uc_file/
src/ Form/ ShowForm.php, line 178
Class
- ShowForm
- Displays all files that may be purchased and downloaded for administration.
Namespace
Drupal\uc_file\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
switch ($form_state
->getValue([
'uc_file_action',
'action',
])) {
case 'uc_file_delete':
$file_ids = [];
if (is_array($form_state
->getValue('file_select'))) {
foreach ($form_state
->getValue('file_select') as $fid => $value) {
if ($value) {
$file_ids[] = $fid;
}
}
}
if (count($file_ids) == 0) {
$form_state
->setErrorByName('', $this
->t('You must select at least one file to delete.'));
}
break;
}
}