我正在尝试使用用户配置文件表单(femanager)从前端上传pdf文件,它只允许我使用“图像”字段,但对于这种情况需要更多pdf文件字段。
我有以下自定义字段
<f:form.upload
id="femanager_field_pdf"
property="pdf.0"
class="custom-file-input" />
在扩展的 User 类中
/**
* @var ObjectStorage<FileReference>
*/
protected $pdf;
/**
* Gets the pdf value
*
* @return ObjectStorage<FileReference>
*/
public function getPdf()
{
return $this->pdf;
}
/**
* Sets the pdf value
*
* @param ObjectStorage<FileReference> $pdf
*/
public function setpdf(ObjectStorage $pdf)
{
$this->pdf = $pdf;
}
我预计在保存用户配置文件表单时,文件将保存在“pdf”字段中,但它会生成错误
Exception while property mapping at property path "pdf.0": Property "name" was not found in target object of type "TYPO3\CMS\Extbase\Domain\Model\FileReference".
对于
fe_manager
,您需要添加一个新的数据处理器。
参见 TypoScript 设置:
plugin.tx_femanager.settings.dataProcessors.100 {
#Classname that should be called with an existing method process()
class = Vendor\Ext\DataProcessor\DoSomethingDataProcessor
#optional: Add configuration for your PHP
config {
foo = bar
fooCObject = TEXT
fooCObject.value = do something with this text
}
#call this class just before this actions will be opened
events {
New = create,createStatus
}
}
然后添加一个新的DataProcessor类。例如,请参见
In2code\Femanager\DataProcessor
。
背景:需要先将图片或PDF上传到服务器。然后需要创建一个sys_file_reference。之后请求参数将更改为新文件 UID。