From 273c0602cbf790f4e21634b26b2a242cdf12a022 Mon Sep 17 00:00:00 2001 From: Harish Karumuthil Date: Sun, 7 Apr 2024 19:37:07 +0530 Subject: [PATCH] Allow extending Form/Control/Upload class by using different JS plugin --- src/Form/Control/Upload.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Form/Control/Upload.php b/src/Form/Control/Upload.php index e0b7d540c3..16e1e25bef 100644 --- a/src/Form/Control/Upload.php +++ b/src/Form/Control/Upload.php @@ -19,6 +19,8 @@ class Upload extends Input public string $inputType = 'hidden'; + public string $jsPluginName = 'atkFileUpload'; + /** * The uploaded file ID. * This ID is return on form submit. @@ -173,7 +175,7 @@ public function onUpload(\Closure $fx): void if (count($postFiles) > 0 && reset($postFiles)['error'] === 0) { $this->addJsAction( - $this->js()->atkFileUpload('updateField', [$this->fileId, $this->getInputValue()]) + $this->js()->{$this->jsPluginName}('updateField', [$this->fileId, $this->getInputValue()]) ); } @@ -236,7 +238,7 @@ protected function renderView(): void $this->template->set('Placeholder', $this->placeholder); } - $this->js(true)->atkFileUpload([ + $this->js(true)->{$this->jsPluginName}([ 'url' => $this->cb->getJsUrl(), 'action' => $this->action->name, 'file' => ['id' => $this->fileId ?? $this->entityField->get(), 'name' => $this->getInputValue()],