- Issue created by @jaypan
- last update
over 1 year ago Patch Failed to Apply - 🇸🇰Slovakia poker10
There are usages in core where
upload_validators
are used with the typefile
. For example inDrupal\system\Form\ThemeSettingsForm
, see: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/syste...$form['logo']['settings']['logo_upload'] = [ '#type' => 'file', '#title' => $this->t('Upload logo image'), '#description' => $this->t("If you don't have direct file access to the server, use this field to upload your logo."), '#upload_validators' => [ 'FileIsImage' => [], ], ];
Based on this I think it is possible to use
upload_validators
on typefile
as well. - Status changed to Closed: works as designed
2 days ago 1:21pm 28 May 2025 - 🇮🇳India mohit_aghera Rajkot
I believe we should close this issue.
There are few more usages of upload validators with the file elmement.
like
Drupal\locale\Form\ImportForm.php
$form['file'] = [ '#type' => 'file', '#title' => $this->t('Translation file'), '#description' => [ '#theme' => 'file_upload_help', '#description' => $this->t('A Gettext Portable Object file.'), '#upload_validators' => $validators, ], '#size' => 50, '#upload_validators' => $validators, '#upload_location' => 'translations://', '#attributes' => ['class' => ['file-import-input']], ];
Feel free to re-open if you feel we still need to alter documentation to mention both the #types of fields.