From 66a2caacc473e1129b482842316b7881aee74d7a Mon Sep 17 00:00:00 2001 From: Dave Long <dave@longwaveconsulting.com> Date: Wed, 16 Apr 2025 13:46:45 +0200 Subject: [PATCH] Issue #3037204 by starlight-sparkle, atowl, dww, kim.pepper: If upload progress extension is not available, disable the file field widget settings (cherry picked from commit 88aafb3633524ff4a5cecb3787075ff838f738cf) --- .../file/src/Plugin/Field/FieldWidget/FileWidget.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index 62db3ddf1a43..a38e64ab53cc 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -12,6 +12,7 @@ use Drupal\Core\Render\Element; use Drupal\Core\Render\ElementInfoManagerInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\Url; use Drupal\file\Element\ManagedFile; use Drupal\file\Entity\File; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -60,6 +61,15 @@ public static function defaultSettings() { * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { + $element['notice'] = [ + '#type' => 'container', + '#markup' => $this->t('The UploadProgress PHP extension must be enabled to configure the progress indicator. Check the <a href=":status">status report</a> for more information.', [':status' => Url::fromRoute('system.status')->toString()]), + '#weight' => 16, + '#access' => !extension_loaded('uploadprogress'), + '#attributes' => [ + 'role' => 'status', + ], + ]; $element['progress_indicator'] = [ '#type' => 'radios', '#title' => $this->t('Progress indicator'), @@ -70,7 +80,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { '#default_value' => $this->getSetting('progress_indicator'), '#description' => $this->t('The throbber display does not show the status of uploads but takes up less space. The progress bar is helpful for monitoring progress on large uploads.'), '#weight' => 16, - '#access' => extension_loaded('uploadprogress'), + '#disabled' => !extension_loaded('uploadprogress'), ]; return $element; } -- GitLab