1 <?php
2
3 4 5 6 7 8
9
10 class SubmittedFileField extends SubmittedFormField {
11
12 static $has_one = array(
13 "UploadedFile" => "File"
14 );
15
16 17 18 19 20
21 function getFormattedValue() {
22 $link = $this->getLink();
23 $title = _t('SubmittedFileField.DOWNLOADFILE', 'Download File');
24
25 if($link) {
26 return sprintf('<a href="%s">%s</a>', $link, $title);
27 }
28
29 return false;
30 }
31
32 33 34 35 36
37 function getLink() {
38 if($file = $this->UploadedFile()) {
39 if(trim($file->getFilename(), '/') != trim(ASSETS_DIR,'/')) {
40 return $this->UploadedFile()->URL;
41 }
42 }
43 }
44 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-