Reputation: 849
I'm trying to do this simple task :
I have a "Company" class which contains :
/**
* @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;
}
the logo property is a document entity.
Here is my CompanyType() :
$builder->add('name', 'text', array(
'required' => false
));
$builder->add('logo', new DocumentType(), array(
'required' => false
));
I'm simply trying to save a new Company but I get this error :
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
I really just followed simple examples on the sf2 cookbook and openclassroom, I don't understand why I'm failing so much. Can someone help me ?
Upvotes: 0
Views: 69
Reputation: 1598
I believe your error is in your custom form type DocumentType. The option 'data_class' must be defined and have the following value: My/Namespace/Model/Document. Modify with wathever your namespace for Document actually is.
If your problem persists, you should provide us with the code of your DocumentType custom field.
Upvotes: 1