我的文档类型中有一些字段" 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);
请帮助解决此问题。