user2752173
user2752173

Reputation: 499

TYPO3 Parent relation reciprocity

I've a TCA problem. There is a relation (m:n) 'parent' which refer to the 'Uid', there is also a 'parent_r' (parent reciprocity) which is read only, and allow the user to see the records related to the current one. I didn't create the 'parent_r' relation in my entity since it is calculated by reference, and don't need to be persisted. I've just used this TCA:

'parent_r' => [
    'config' => [
        'type' => 'group',
        'internal_type' => 'db',
        'allowed' => 'tx_myext_domain_model_entity',
        'foreign_table' => 'tx_myext_domain_model_entity',
        'MM_opposite_field' => 'parent',
        'MM' => 'tx_myext_entity_parent_entity_mm',
        'readOnly' => true,
    ],
],

I get the following error message on saving a record:

(1/2) Doctrine\DBAL\Exception\InvalidFieldNameException
An exception occurred while executing 'SELECT uid, l10n_parent... FROM tx_myext_domain_model_entity WHERE uid = ?' with params [40]: Unknown column 'parent_r' in 'field list'

What am I missing in MM_opposite_field? Do I really need to create a 'parent_r' propriety in my entity, since it is already stored?

Upvotes: 1

Views: 91

Answers (1)

Oliver Hader
Oliver Hader

Reputation: 4203

Do I really need to create a 'parent_r' propriety in my entity, since it is already stored?

Yes, (standard) TYPO3 requires to have those fields being declared in database tables. parent_r in your case should be of type int and will be filled with the reference count for corresponding entity relationships.

Upvotes: 1

Related Questions