[TYPO3-mvc] Property / relation problem

Alexander Dick typo3 at dick.at
Fri Feb 3 13:41:06 CET 2012


Hey Claus,

Am 03.02.2012 13:13, schrieb Claus Due:
> Hi Alex,
>
>> I have now created a table tx_xxx_domain_model_staticcountry (copied the structure from static_countries) and added proper TCA configuration for it.
>>
>> The error persists.
>
> My bugfixing sense says "show us the TCA for the column on your parent object that points to the Country"... and to try manually testing if you can 1) create an instance of your Country then 2) setCountr($country) on your intended object and 3) persist that object - if the DB contents are incorrect here we should look for the cause in either TCA, TS mapping info or other cannot-get-TS issues that could rise from the context you are in.
>
> If your context is any other than rendering a plugin through a Web Request let us know which :)

I tried to set it manually and it works!

$countryRepository = 
$this->objectManager->get('Tx_Xxx_Domain_Repository_StaticCountryRepository');
$country = $countryRepository->findByUid(14);
$this->user->setCountry($country);
$this->persistenceManager->persistAll();

afterwards I assign $this->user to the template variable 'user' and I 
can access the country name in the template via {user.country.title}

The problem only occurs when saving through the form.

The form field has the name

tx_xxx_controllername[user][country]

or when it's being prefilled (in edit mode)
tx_xxx_controllername[user][country][__identity]

value is the UID of a static_country record.

both lead to the same exception.

country column in TCA:

'country' => array(
	'exclude' => 0,
	'label' => 'Country',
	'config' => array(
		'type' => 'select',
		'size' => 1,
		'items' => array(
			array('', 0),
		),
		'foreign_table' => 'tx_xxx_domain_model_staticcountry',
		'maxitems' => 1
	),
),

I have other columns with relations to domain objects where not even a 
foreign_table is defined, but everything's working.

>
>> Doesn't extbase use the TCA from static_countries when I map the model to this table? ( Tx_Xxx_Domain_Model_StaticCountry.mapping.tableName = static_countries )
>
> Yes, it does - but perhaps more is necessary to enable it or perhaps some other circumstance is causing the TS to not be read. I admit never doing this type of relation - I've only worked with extending the FrontendUser and FrontendUserGroups, never mapping a non-standard TYPO3 table to a standard Extbase Model...
>
>> EXT extbase_staticinfotables does not help me out in this case. It only contains 1 Country model and has the same mapping to static_countries than I do in my extension.
>
> But perhaps the manual has a step-by-step how to integrate in your own models, which you could check to see if you missed something. Perhaps you could use that ext as a reference for TS, TCA etc.?
>

Unfortunately there is no manual, it's only the manual template..

> --
> Cheers,
> Claus
> http://fedext.net



More information about the TYPO3-project-typo3v4mvc mailing list