【发布时间】:2018-02-01 18:36:23
【问题描述】:
我有一个叫做“邮件”的普通模型:
Namespace ...
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class Mail extends AbstractEntity
{
/**
* @var string
*/
protected $name;
protected $company;
.../**
* @var string
*/
protected $company;
...
我想在表单中使用它:
<f:form action="post" object="{mail}">
<f:form.textfield property="name"/>
...
</f:form>
第一个奇怪的是,viewhelper 生成的 html 是:
<input name="tx_myext_offer[name]">
但为了工作,它应该是:
<input name="tx_myext_offer[mail][name]">
所以我尝试使用“tx_myext_offer[mail][name]”之类的名称属性手动编写输入字段的 html。 当我现在将表单发送到控制器时,我收到一个错误:
#1297759968: Exception while property mapping at property path "": It is not allowed to map property "name". You need to use $propertyMappingConfiguration->allowProperties('name') to enable mapping of this property.
当我调试请求的 PropertyMappingConfiguration 对象时,我看到“propertiesNotToBeMapped”属性为空。应该有Mail模型的属性。
不知何故 extbase 这次没有自动映射它。好像我在某个地方错过了什么。如何告诉 extbase 自动映射 Model 的属性?
@ThomasLöffler
在调用表单的控制器 Action 中没有任何令人兴奋的事情发生:
公共函数 showAction() {
$this->view->assignMultiple(
[
'mail' => $this->objectManager->get(Mail::class)
]
);
}
【问题讨论】:
-
你能发布调用这个表单的控制器动作吗?
-
阅读此文档。可能对你有用。 wiki.typo3.org/Exception/CMS/….
-
@PravinVavadiya 谢谢,我知道这些“文档”,它们与错误消息相关联。但是这里没有一个案例适用于我。我想真正找出问题所在,以便 extbase 不会自动进行属性映射。