如何获取 Symfony 嵌入式动态表单未映射数据

问题描述 投票:0回答:1
symfony symfony-forms
1个回答
0
投票

您的 FormType 是您的父表单还是 CollectionType 类型的子表单?

如果它是子表单,如本文访问嵌入式表单数据中所述,您可以尝试以下操作:

foreach ($project->getTeams() as $key => $coordinator) { 
    $coordinatorImage = $teamImageUpload->uploadTeamImage(
            $form->get('teams')[$key]['cropped_file']->getData(), 
            $coordinator
    ); 
    $coordinator->setImage($coordinatorImage); 
}

这将允许您浏览您的收藏并查看它们包含的内容`。

否则,您应该考虑使用 Symfony 文档中的嵌入式表单集合

© www.soinside.com 2019 - 2024. All rights reserved.