From 906a4e65c287e4d16e79502afd960474f9abaa5f Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Fri, 28 Aug 2015 04:39:29 +1000 Subject: [PATCH] Prompt can now be used to define the button text for file multi Minor update to checkbox markup --- modules/backend/formwidgets/FileUpload.php | 22 ++++++++++++++++--- .../fileupload/partials/_file_multi.htm | 4 ++-- modules/system/assets/ui/docs/checkbox.md | 8 +++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/modules/backend/formwidgets/FileUpload.php b/modules/backend/formwidgets/FileUpload.php index c488b9093..f6470830a 100644 --- a/modules/backend/formwidgets/FileUpload.php +++ b/modules/backend/formwidgets/FileUpload.php @@ -34,9 +34,9 @@ class FileUpload extends FormWidgetBase // /** - * @var string Prompt to display if no record is selected. + * @var string Prompt text to display for the upload button. */ - public $prompt = 'backend::lang.fileupload.default_prompt'; + public $prompt = null; /** * @var int Preview image width @@ -126,7 +126,7 @@ class FileUpload extends FormWidgetBase $this->vars['cssDimensions'] = $this->getCssDimensions(); $this->vars['cssBlockDimensions'] = $this->getCssDimensions('block'); $this->vars['useCaption'] = $this->useCaption; - $this->vars['prompt'] = str_replace('%s', '', trans($this->prompt)); + $this->vars['prompt'] = $this->getPromptText(); } protected function getFileList() @@ -166,6 +166,22 @@ class FileUpload extends FormWidgetBase return $mode; } + /** + * Returns the escaped and translated prompt text to display according to the type. + * @return string + */ + protected function getPromptText() + { + if ($this->prompt === null) { + $isMulti = ends_with($this->getDisplayMode(), 'multi'); + $this->prompt = $isMulti + ? 'backend::lang.fileupload.upload_file' + : 'backend::lang.fileupload.default_prompt'; + } + + return str_replace('%s', '', e(trans($this->prompt))); + } + /** * Returns the CSS dimensions for the uploaded image, * uses auto where no dimension is provided. diff --git a/modules/backend/formwidgets/fileupload/partials/_file_multi.htm b/modules/backend/formwidgets/fileupload/partials/_file_multi.htm index f4baf3050..6ae8c2d6b 100644 --- a/modules/backend/formwidgets/fileupload/partials/_file_multi.htm +++ b/modules/backend/formwidgets/fileupload/partials/_file_multi.htm @@ -11,8 +11,8 @@ > - diff --git a/modules/system/assets/ui/docs/checkbox.md b/modules/system/assets/ui/docs/checkbox.md index addbba6d9..a286b62e6 100644 --- a/modules/system/assets/ui/docs/checkbox.md +++ b/modules/system/assets/ui/docs/checkbox.md @@ -5,22 +5,22 @@ Allows a user to select from a small set of binary options.
- +
### Radio
- +
- +
- +