数组收集错误虽然是presist文档Symfony2.8

时间:2016-08-03 04:57:21

标签: mongodb symfony

我的文档类型中有一些字段" Collection"。因此,当我尝试保存文档时,我遇到了以下错误。

 " Collection type requires value of type array or null, Doctrine\Common    \Collections\ArrayCollection given. even All the field which are collection types are defined as :"

$byLedgersArrays = array(0=>112,1=>566);    
$document->addToLedgers($byLedgersArrays);

//My Document is this:
/**
 * @var array $byLedgers
 *
 * @ODM\Field(name="byLedgers", type="collection")
 */
protected $byLedgers;
public function __construct()
{
    $this->setIsDeleted(false);       
    $this->byLedgers = new ArrayCollection();
}
//Controller:
$document = new Voucher();
$document->addByLedgers($byLedgersArrays);

请帮助解决此问题。

0 个答案:

没有答案