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 三菱FX系列PLC串口指令
  • ¥15 cocos的js代码调用wx.createUseInfoButton问题!
  • ¥15 关于自相关函数法和周期图法实现对随机信号的功率谱估计的matlab程序运行的问题,请各位专家解答!
  • ¥15 Python程序,深度学习,有偿私
  • ¥15 扫描枪扫条形码出现问题
  • ¥35 poi合并多个word成一个新word,原word中横版没了.
  • ¥15 【火车头采集器】搜狐娱乐这种列表页网址,怎么采集?
  • ¥15 求MCSCANX 帮助
  • ¥15 机器学习训练相关模型
  • ¥15 Todesk 远程写代码 anaconda jupyter python3