【问题标题】:Cascade delete TYPO3 inline records don't work级联删除TYPO3内联记录不起作用
【发布时间】:2019-07-05 06:45:21
【问题描述】:

我有一些产品的 TYPO3 扩展,它使用内联记录将文档组添加到产品中。删除产品还应删除文档组(内联记录)。

文档说behaviour.enableCascadingDelete 默认设置为true,但不会删除文档组。在 TCA 中设置此值没有任何区别。

'documentgroups' => [
    'exclude' => 1,
    'label' => $ll . ".documentgroups",
    'config' => [
        'type' => 'inline',
        'allowed' => 'tx_product_domain_model_docgroup',
        'behaviour' => [
            'allowLanguageSynchronization' => true,
            'enableCascadingDelete' => true,
        ],
        'foreign_table' => 'tx_product_domain_model_docgroup',
        'MM'            => 'tx_product_mm',
        'MM_match_fields' => [
            'tablenames' => 'tx_product_domain_model_docgroup',
            'fieldname' => 'documentgroups',
            'table_local' => $tableName,
        ],
        'foreign_sortby' => 'sorting',
        'minitems' => 0,
        'maxitems' => 99,
    ]
],

【问题讨论】:

  • 那可能是因为你使用的是MM关系。使用 MM 从技术上讲,您的 docgroup 记录可能会反向引用其他记录,因此删除它们可能不合理。不过只是猜测。
  • 嗨@Nitori,经过一些调试,我可以确认你的猜测。如果是 MM 关系级联删除将不起作用。这可以通过查看\TYPO3\CMS\Core\DataHandling\DataHandler->deleteRecord_procBasedOnFieldType 和 ``\TYPO3\CMS\Core\DataHandling\DataHandler->getInlineFieldType` 来验证

标签: typo3 typo3-9.x


【解决方案1】:

enableCascadingDelete 对 MM 相关表没有影响。在\TYPO3\CMS\Core\DataHandling\DataHandler->deleteRecord_procBasedOnFieldType 中检查内联类型,并且仅当它的类型为field(必须在TCA 中设置foreign_field)或listMMforeign_field 不得在TCA 中设置)子条目将被删除。

【讨论】:

    猜你喜欢
    • 2013-06-22
    • 2013-03-03
    • 2012-11-18
    • 2011-06-11
    • 2018-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多