dousha1873 2018-08-11 19:38
浏览 21
已采纳

symfony 3.4.14 collectionType编辑和删除问题

i have two table in the database that user and Files that each user can have multilpe image so i used Collectiontype for adding multiple image create and read are working well but when i try to edit them i get this error screenshot

i looked every documention but i couldn't find anything to solve my problem here's what i have in usertype and Filestype https://gist.github.com/Bakhshi-Faisal/ffa62cc6b059f662243cf7e2564a03ef

  • 写回答

2条回答 默认 最新

  • douwanc63652 2018-08-12 18:30
    关注

    you need to change your form types accordingly:

    class UserType extends AbstractType {
    
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('lastName')
            ->add('files',CollectionType::class, array(
                  'entry_type' => AppBundle\Form\FilesType::class,
                  'allow_add' => true,
                  'allow_delete' => true,
            ));
    ...
    
    class FilesType extends AbstractType {
    
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('file',FileType::class, array(
                  'data_class' => null
            ));
    ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型