我试着做这个简单的任务:
我有一个“公司”课程,其中包括:
/**
* @var Document
*/
private $logo;
/**
* Set logo
*
* @param Document $logo
* @return Company
*/
public function setLogo(Document $logo = null)
{
$this->logo = $logo;
return $this;
}
/**
* Get logo
*
* @return Document
*/
public function getLogo()
{
return $this->logo;
}logo属性是文档实体。
这是我的CompanyType():
$builder->add('name', 'text', array(
'required' => false
));
$builder->add('logo', new DocumentType(), array(
'required' => false
));我只是想拯救一家新公司,但我得到了这样的错误:
ContextErrorException: Catchable Fatal Error: Argument 1 passed to
Proxies\__CG__\Teacup\UserBundle\Entity\Company::setLogo() must be an instance of
Teacup\FileBundle\Entity\Document, array given, called in
/Users/jansel/Sites/spm/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php
on line 360 and defined in
/Users/jansel/Sites/spm/app/cache/dev/doctrine/orm/Proxies/__CG__TeacupUserBundleEntityCompany.php line 293我真的只是在sf2烹饪书和开放教室上学习简单的例子,我不明白为什么我会失败这么多。有人能帮我吗?
发布于 2014-03-27 14:12:37
我相信您的错误在您的自定义表单类型DocumentType中。选项'data_class‘必须定义并具有以下值:用动摇修改文档的名称空间。
如果您的问题仍然存在,您应该向我们提供DocumentType自定义字段的代码。
https://stackoverflow.com/questions/22688053
复制相似问题