Forms Symfony 4:其中是CollectionType的逻辑';s";允许“删除”;选项

Forms Symfony 4:其中是CollectionType的逻辑';s";允许“删除”;选项,forms,symfony4,Forms,Symfony4,所以,我试图理解Symfony形式。我正在搜索核心代码中的“allow_delete”选项,看看它在引擎盖下是如何工作的,但唯一可以找到它的地方是CollectionType类,我在那里找不到任何逻辑 文件: 如果设置为true,则如果现有项未包含在 提交的数据,将正确地从最终的 项目 在代码中,它到底影响了提交的数据在哪里?您可以在第91行开始的MergeCollectionListener.php中找到该函数: // Remove deleted items before adding to

所以,我试图理解Symfony形式。我正在搜索核心代码中的“allow_delete”选项,看看它在引擎盖下是如何工作的,但唯一可以找到它的地方是
CollectionType
类,我在那里找不到任何逻辑

文件:

如果设置为true,则如果现有项未包含在 提交的数据,将正确地从最终的 项目


在代码中,它到底影响了提交的数据在哪里?

您可以在第91行开始的
MergeCollectionListener.php
中找到该函数:

// Remove deleted items before adding to free keys that are to be
// replaced
if ($this->allowDelete) {
        foreach ($itemsToDelete as $key) {
            unset($dataToMergeInto[$key]);
        }
    }
$dataToMergeInto
设置为
$dataToMergeInto=$event->getForm()->getNormData();
指的是在
FormInterface.php
中解释的函数:

/**
 * Returns the normalized data of the field.
 *
 * @return mixed When the field is not submitted, the default data is returned.
 *               When the field is submitted, the normalized submitted data is
 *               returned if the field is valid, null otherwise.
 */
public function getNormData();