TYPO3 8.7 / Extbase "No Properties to be mapped"

时间:2018-02-01 18:36:23

标签: typo3 extbase

I have an ordninary model called "Mail":

Namespace ...
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

class Mail extends AbstractEntity
{
    /**
     * @var string
     */
    protected $name;
    protected $company;

.../**
     * @var string
     */
    protected $company;

...

I want to use it in a Form:

<f:form action="post" object="{mail}">
    <f:form.textfield property="name"/>
    ...
</f:form>

First weird thing is, the html the viewhelper generates is:

<input name="tx_myext_offer[name]">

But in order to work it should be:

 <input name="tx_myext_offer[mail][name]">

So I try to write the html of the input field manualy with the name attribute like "tx_myext_offer[mail][name]". When I now send the form to the controller I get an error:

#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. 

When I debug the PropertyMappingConfiguration Object of the request I see that the "propertiesNotToBeMapped" Attribute is empty. There should be the attributes of the Mail model.

Somehow extbase does not map it automatically this time. Seems like I missed something somewhere. How can I tell extbase to map the the properties of the Model automatically?

@ThomasLöffler

in the controller Action which calls the form there is nothing exciting happening:

public function showAction() {

$this->view->assignMultiple(
    [
        'mail' => $this->objectManager->get(Mail::class)
    ]
);

}

1 个答案:

答案 0 :(得分:1)

首先是第一件事。您错过了objectName="mail"代码中的<f:form />属性。

当您添加此属性时,隐藏字段tx_myext_offer[__trustedProperties]和其他一些字段将会更改,然后您的自动属性映射应该有效。