FIX Fixing plain email blank file field value (#940)

* Fixing plain email blank file field value
This commit is contained in:
3Dgoo 2020-07-01 06:30:31 +09:30 committed by GitHub
parent 8c2d9a9438
commit 6ca8ce2596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -25,6 +25,7 @@ use SilverStripe\UserForms\Form\UserForm;
use SilverStripe\UserForms\Model\EditableFormField;
use SilverStripe\UserForms\Model\EditableFormField\EditableFileField;
use SilverStripe\UserForms\Model\Submission\SubmittedForm;
use SilverStripe\UserForms\Model\Submission\SubmittedFileField;
use SilverStripe\UserForms\Model\UserDefinedForm;
use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements;
@ -416,7 +417,11 @@ JS
$body = strip_tags($recipient->getEmailBodyContent()) . "\n";
if (isset($emailData['Fields']) && !$emailData['HideFormData']) {
foreach ($emailData['Fields'] as $field) {
$body .= $field->Title . ': ' . $field->Value . " \n";
if ($field instanceof SubmittedFileField) {
$body .= $field->Title . ': ' . $field->ExportValue ." \n";
} else {
$body .= $field->Title . ': ' . $field->Value . " \n";
}
}
}

View File

@ -61,7 +61,8 @@ class SubmittedFileField extends SubmittedFormField
*/
public function getLink()
{
if ($file = $this->UploadedFile()) {
$file = $this->UploadedFile();
if ($file && $file->exists()) {
if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) {
return $this->UploadedFile()->AbsoluteLink();
}