mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
ENHANCEMENT: Don't return a blank url when no file is specified
This commit is contained in:
parent
982ea1cdb1
commit
abee24ed0c
@ -17,7 +17,8 @@ class SubmittedFileField extends SubmittedFormField {
|
||||
* @return String
|
||||
*/
|
||||
function getFormattedValue() {
|
||||
return '<a href="'.$this->getLink().'">'. _t('SubmittedFileField.DOWNLOADFILE', 'Download File') .'</a>';
|
||||
$link = $this->getLink();
|
||||
return (!empty($link)) ? '<a href="'.$link.'">'. _t('SubmittedFileField.DOWNLOADFILE', 'Download File') .'</a>' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -26,6 +27,10 @@ class SubmittedFileField extends SubmittedFormField {
|
||||
* @return String
|
||||
*/
|
||||
function getLink() {
|
||||
return ($this->UploadedFile()) ? $this->UploadedFile()->URL : "";
|
||||
if ($this->UploadedFile()){
|
||||
// Test if there is a filename, not only a filepath to the assets folder
|
||||
return ($this->UploadedFile()->getFilename() != ASSETS_DIR.'/') ? $this->UploadedFile()->URL : '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user