[TYPO3-mvc] Problem with Property mapping

Helmut Hummel helmut.hummel at typo3.org
Tue Dec 23 01:20:41 CET 2014


Hi Eike!

Am 12.06.14 um 12:51 schrieb Eike Starkmann:

> Situation:
>
> Model:
> class A{
> 	protected aThing;
> }
>
> class B extends A{
> 	protected bThing;
> }
>
>
> Now i have an edit mask in FE. I want to use just one editAction for
> both types:
>
> public editAction(\Something\A $a){
> .....
> }
>
> public updateAction(\Something\A $a){....}
>
> In fuild I have template like this:
>
> ....
>
> <f:if condtion="a.type=tx_..._a">
> 	<f:form.textfield property="a" />
> </if>
> <f:if condtion="a.type=tx_..._b">
> 	<f:form.textfield property="b" />
> </if>
>
> But when i edit type b and press edit "Save" button i get this error:
>
> Exception while property mapping at property path "":Property "b" was
> not found in target object of type "...\Wall\Domain\Model\A"

The target type for property mapping is determined by the action method 
argument type. Thus, it is always set to \Something\A. But you can 
optionally pass the type information and the object converter will then 
take care to set the target type accordingly:

<f:if condtion="a.type=tx_..._b">
  	<f:form.textfield property="b" />
	<f:form.hidden name="tx_yourplugin[a][__type]" 
value="\Wall\Domain\Model\B" />
</if>

See: 
https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/extbase/Classes/Property/TypeConverter/ObjectConverter.php#L175


Kind regards,
Helmut

-- 
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 CMS Active Contributor, TYPO3 Security Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-project-typo3v4mvc mailing list