我的域模型中有 am:n 关系:
- 查询是我的域模型中的聚合根
- 可以为每个调查分配几个调查员。
在查询模型中定义为:
/**
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_MyExt_Domain_Model_Investigator>
*/
protected $investigator;
调查者域模型映射到 TYPO3 的fe_user表,在配置 ( ) 中正确注明ext_typoscript_setup.txt
:
config.tx_extbase{
persistence{
classes{
Tx_MyExt_Domain_Model_Investigator {
mapping {
recordType = Tx_Extbase_Domain_Model_FrontendUser
tableName = fe_users
}
}
}
这很好用,我可以在后端和前端显示和编辑查询记录。但是,当我想更改分配给一个查询的调查员(从编辑操作)时,我在提交表单后遇到异常:
#1297759968: Exception while property mapping at property path "investigator":
No converter found which can be used to convert from "array" to
"Tx_Extbase_Persistence_ObjectStorage"
我用于此的多选框是这样创建的:
<f:form.select multiple="true" size="10" property="investigator"
value="{inquiry.investigator}" options="{allInvestigators}"
optionLabelField="name" />
呈现如下:
<select name="tx_myext_inquiry[inquiry][investigator][]" size="10" multiple="true">
<option value="362">John Doe</option>
<option value="590">Jane Doe</option>
<option selected="selected" value="361">Steve Miller</option>
<option value="720">James Brown</option>
<option value="726">Janis Joplin</option>
</select>
{allInvestigators}
是一个包含来自“调查员”组的所有用户的数组。已经存储的值标有“已选择”,这证明我的某些代码是正确的;)。
我尝试摆弄 InquiryController 中的类型转换器(Tx_Extbase_Property_TypeConverter_PersistentObjectConverter
Dok)以将我的数组转换为一个对象,但它无济于事。字段调查器作为数组传递给触发异常的更新操作。
我现在花了五个小时,需要继续前进。
- 我怎样才能摆脱这个错误信息?
- 将数组转换为对象是正确的方法吗?
(任何关于更多细节的问题将尽快得到答复)
编辑:
环境:TYPO3 版本 6.1.1,流体 6.1.0,Extbase 6.1.0