TYPO3 8.7 / Extbase "No Properties to be mapped"
TYPO3 8.7 / Extbase "No Properties to be mapped"
我有一个普通型号叫"Mail":
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 自动映射模型的属性?
@ThomasLöffler
在调用表单的控制器 Action 中没有发生任何令人兴奋的事情:
public 函数 showAction()
{
$this->view->assignMultiple(
[
'mail' => $this->objectManager->get(Mail::class)
]
);
}
第一件事。您在 <f:form />
标签中遗漏了属性 objectName="mail"
。
当您添加此属性时,隐藏字段 tx_myext_offer[__trustedProperties]
和许多其他字段将发生变化,然后您的自动 属性 映射应该可以工作。
我有一个普通型号叫"Mail":
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 自动映射模型的属性?
@ThomasLöffler
在调用表单的控制器 Action 中没有发生任何令人兴奋的事情:
public 函数 showAction() {
$this->view->assignMultiple(
[
'mail' => $this->objectManager->get(Mail::class)
]
);
}
第一件事。您在 <f:form />
标签中遗漏了属性 objectName="mail"
。
当您添加此属性时,隐藏字段 tx_myext_offer[__trustedProperties]
和许多其他字段将发生变化,然后您的自动 属性 映射应该可以工作。