简体   繁体   English

尝试在表单中创建实体字段时出现Symfony2错误

[英]Symfony2 error when trying to create entity field in form

$tip->setGame($em->getRepository('XXXBundle:Game')->find($id));
        $form = $this->createFormBuilder($tip)->add('player', 'entity', array(
        'class' => 'XXXBundle::FootballPlayer',
        /*'query_builder' => function(\XXX\XXXBundle\Entity\FootballPlayerRepository $er)
        {
          $er->findByCurteam($team->getName());
        },*/
    ))->getForm();

(not really using 'XXX' in my code) error: (在我的代码中未真正使用“ XXX”)错误:

Warning: class_parents(): Class XXX\\XXXBundle\\Entity\\ does not exist and could not be loaded in D:\\www\\xxx\\xxx\\vendor\\doctrine\\lib\\Doctrine\\ORM\\Mapping\\ClassMetadataFactory.php line 223 警告:class_parents():类XXX \\ XXXBundle \\ Entity \\不存在,并且无法在D:\\ www \\ xxx \\ xxx \\ vendor \\ doctrine \\ lib \\ Doctrine \\ ORM \\ Mapping \\ ClassMetadataFactory.php行中加载

seems the Entity class is not found - strange 似乎找不到Entity类-奇怪

Something is strange in your code: 'class' => 'XXXBundle::FootballPlayer', are you sure :: exist? 您的代码中有些奇怪: 'class' => 'XXXBundle::FootballPlayer',您确定::存在吗? Never seen it, seems like a mistake (maybe can provoke the error). 从未见过,似乎是一个错误(可能会引起错误)。

After testing, yes, it's because of the double :: replace by : : 'class' => 'XXXBundle:FootballPlayer', . 经检测,是的,这是因为双::通过更换:'class' => 'XXXBundle:FootballPlayer',

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM