TYPO3 使 ExtbaseGuide 示例工作,设置类别

TYPO3 make ExtbaseGuide example working, get set category

我按照 TYPO3 文档中的“Creating an Extbase extension”构建了产品概述,一切正常。

下一步教“Extending an Extbase extension”,这也行得通,但最后一步更改了 TCA,以便 select 存储类别而不是内联添加它们 ...

列表显示 selection 可能性与创建的类别,我可以 select 它们但它们不保存,如果我检查数据库,类别已保存但它没有显示在后端,typo3 无法识别字段中保存的类别...

谁能给出让它工作所需的最后步骤...(我已经安装、卸载、清除缓存、使用安装工具清理等多次...)

这是我的 tca:

/* original working inline code
        'categories' => [
            'exclude' => 1,
            'label' => 'LLL:EXT:productoverview/Resources/Private/Language/locallang_db.xlf:tx_productoverview_domain_model_product.categories',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_productoverview_domain_model_category',
                'foreign_field' => 'product',
                'maxitems' => 9999,
                'appearance' => [
                    'collapseAll' => 0,
                    'levelLinksPosition' => 'top',
                    'showSynchronizationLink' => 1,
                    'showPossibleLocalizationRecords' => 1,
                    'showAllLocalizationLink' => 1
                ],
            ],

        ],
suggested category selection */
        'categories' => [
          'exclude' => 0,
          'label' => 'LLL:EXT:productoverview/Resources/Private/Language/locallang_db.xml:tx_productoverview_domain_model_product.categories',
          'config' => [
            'type' => 'select',
            'renderType' => 'selectMultipleSideBySide',
            'foreign_table' => 'tx_productoverview_domain_model_category',
            'foreign_field' => 'product',
            'maxitems'      => 9999,
          ],
        ],

    ],
];

更新: 我发现 this answer of 2 years 之前在 v7.6.14 中给出了一个错误,但解释了很多,我仍然希望在这里有一个更简单的答案.. .

几天前更新旧项目时遇到了同样的问题。对我来说解决问题的方法是在 type=select: https://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Select/Index.html#rendertype

之外定义一个 renderType

我确实尝试了 j4k3 的解决方案(因为其他有经验的开发人员也建议了它)但是我无法让它在我的本地主机上工作并且从未找到原因(仍然对此感兴趣,我 运行 xampp 上 windows 7 pro) ...

最终我确实找到了一个对我有用的解决方案,它非常简单: 在当前的扩展构建器中,您可以选择 select 来自 select 列表的 关系类型

我把这个(在 ExtbaseGuide 中从未提及)留给 1:n 因为这是实际需要的关系,但现在我使用了 m:n 并且我的麻烦消失了,构建器会自动创建一个额外的MM 关系 table 和完整的 TCA 代码,在构建器保存扩展后直接工作 ...