Typo3 Error: The ColumnMap for property is missing (m:n)

允我心安 提交于 2019-12-13 03:46:51

问题


I am having the same issue that was posted here:

Typo3 Error: The ColumnMap for property is missing

...except I am using a m:n relational table. Unfortunately my error continues:

I'm using Typo3 version 8.7.19 and I'm developing an extention. The two tables "mitarbeiter" and "zusatzlich" are connectet with a m:n relation. I try to search for a field in the table "zusatzlich" in the repository of "mitarbeiter". The relation of both is necessary.

If I try to execute the following query I get the error "The ColumnMap for property "tx_khsjmitarbeiter_domain_model_zusatzlich" of class "...\Mitarbeiter" is missing."

    $query =  $this->createQuery();

    $zu = [];

    if($zusatz1 != ""){
        $zu[] = $query->equals('tx_khsjmitarbeiter_domain_model_zusatzlich.zusatz', $zusatz1);
    }

    if(count($zu)>0){
        $query->matching($query->logicalAnd( $zu ));
    }

    return $query->execute();

The relevant TCA code of the field "connection_id" in "mitarbeiter" which contains the UID of "zusatzlich":

'connection_id' => [
        'exclude' => true,
        'label' => 'LLL:EXT:khsj_mitarbeiter/Resources/Private/Language/locallang_db.xlf:tx_khsjmitarbeiter_domain_model_mitarbeiter.connection_id',
        'config' => [
            'type' => 'select',
            'renderType' => 'selectCheckBox',
            'foreign_table' => 'tx_khsjmitarbeiter_domain_model_zusatzlich',
            'MM' => 'tx_khsjmitarbeiter_mitarbeiter_zusatzlich_mm',
        ],

    ],

This is the object model:

/**
 * connectionId
 *
 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\..\Model\Zusatzlich>
 * @cascade remove
 */
protected $connectionId = null;


/**
 * Initializes all ObjectStorage properties
 * Do not modify this method!
 * It will be rewritten on each save in the extension builder
 * You may modify the constructor of this class instead
 *
 * @return void
 */
protected function initStorageObjects()
{
    $this->connectionId = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}

/** * Adds a Zusatzlich * * @param ..\Model\Zusatzlich $connectionId * @return void */ public function addConnectionId(..\Model\Zusatzlich $connectionId) { $this->connectionId->attach($connectionId); }

/**
 * Removes a Zusatzlich
 *
 * @param \..\Model\Zusatzlich $connectionIdToRemove The Zusatzlich to be removed
 * @return void
 */
public function removeConnectionId(\..\Model\Zusatzlich $connectionIdToRemove)
{
    $this->connectionId->detach($connectionIdToRemove);
}

/**
 * Returns the connectionId
 *
 * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\..\Model\Zusatzlich> connectionId
 */
public function getConnectionId()
{
    return $this->connectionId;
}

/**
 * Sets the connectionId
 *
 * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\..\Model\Zusatzlich> $connectionId
 * @return void
 */
public function setConnectionId(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $connectionId)
{
    $this->connectionId = $connectionId;
}

I can add and apply new zusatz items in the BE to any mitarbeiter item so I am confident it is set up properly in that respect. However I also noticed that if I change this line:

$zu[] = $query->equals('tx_khsjmitarbeiter_domain_model_zusatzlich.zusatz', $zusatz1);

...to this...

$zu[] = $query->equals('ANYTHINGATALL.zusatz', $zusatz1);

I get the same error referencing ANYTHINGATALL instead of tx_khsjmitarbeiter_domain_model_zusatzlich

Can anybody point me in the right direction?


回答1:


You need to supply a property that is described in the TCA as constraint operator, not a table column. As far as I can tell, your query constraint should be:

if($zusatz1 != ""){
        $zu[] = $query->contains('connection_id', $zusatz1);
}


来源:https://stackoverflow.com/questions/52407286/typo3-error-the-columnmap-for-property-is-missing-mn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!