我的域模型中有一个m:n关系:
-
inquiry是我的域模型中的聚合根
-
可以为每个调查分配几名调查员 .
在查询模型中定义:
/**
* @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}
是一个包含"investigators"组中所有用户的数组 . 已存储的值标有"selected",这证明我的一些代码是正确的;) .
我试着在InquiryController中使用类型转换器( Tx_Extbase_Property_TypeConverter_PersistentObjectConverter
Dok)摆弄,将我的数组转换为对象,但无济于事 . 字段调查器作为数组传递给更新操作,从而触发异常 .
我现在花了五个小时,需要继续前进 .
-
How can I get rid of this error message?
-
Is converting the array to an object the right approach at all?
(有关更多细节的任何问题将尽快回答)
Edit:
环境:TYPO3版本6.1.1,Fluid 6.1.0,Extbase 6.1.0
3 回答
我在
Classes/Domain/Model/Inquiry.php
中找到了模型定义中的罪魁祸首我更改(部分)@var注释以命名空间样式:
现在更新过程有效 . 我想在我们的项目中,我们需要标准化模型以命名空间 . 如果这是一个错误,我将在forge.typo3.org上提交 .
这是目前TYPO3的6. *分支中的已知问题 .
请参阅http://forge.typo3.org/issues/54289目前有一个待修复的修补程序可以修复此问题 .
我用GIT的TYPO3 6.1和TYPO3 6.2-dev进行了测试,无法重现这个问题 . 所以如果你能放弃一些环境信息会很好 . 请从您当前的TYPO3版本开始 .