The form's view data is expected to be an instance of class … but is a(n) string

前端 未结 2 456
旧巷少年郎
旧巷少年郎 2021-01-11 19:15

I am currently receiving the following error:

\"The form\'s view data is expected to be an instance of class Symfony\\Component\\HttpFoundation\\File

2条回答
  •  臣服心动
    2021-01-11 19:46

    Here is the answer:

    {
          $builder
              ->add('file', FileType::class, array('data_class' => null))
              ->add('coverFile', FileType::class, array('data_class' => null))
              ->add('coverFile', FileType::class, array('data_class' => null,'required' => false))
              ->add('songName', TextType::class)
              ->add('songAuthor', TextType::class);
      }
    

提交回复
热议问题