dsgrgaz321973284 2017-05-26 08:33
浏览 20
已采纳

Silverstripe Dropzone:文件附件字段保存文件但不附加它

I am working on a frontend form witch gives users the ability to upload files. I almost managed to get FileAttachmentField working. It uploads the file to the desired folder but im not able to attache the uploaded file to it. The relation is a $has_one.

    $fields->push(FileAttachmentField::create('BusinessLicense', 'Business License')
        ->setAcceptedFiles(['.pdf','.doc','.docx'])
        ->setFolderName($MemberID)
        ->setValue(null, $this)

The code above does not attach the file. If I change it to an UploadField like this:

    $fields->push(UploadField::create('IdentityCard', 'Identity Card, Passport, Driving license')
        ->setFolderName($MemberID)
        ->setValue(null, $this)
    );

it works. As far as I understood the docs I have to replace UploadField with FileAttachmentField. Can anyone please give me a hint. I tried hard to get this working. I don't see what I am doing wrong or what I am missing.

  • 写回答

1条回答 默认 最新

  • drmgg4411 2017-05-26 10:29
    关注

    When saving into a $has_one relation you often need the ID suffix though some fields have some custom magic and work without it.

    So something like

    $fields->push(FileAttachmentField::create('BusinessLicenseID', 'Business License')
    

    should work

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题