I'm trying to add entries to a Matrix block with one field type of 'entry' using the following:
$block = new MatrixBlockModel();
$block->fieldId = 9; // Matrix field's ID
$block->ownerId = $collectionID; // ID of entry the block should be added to
$block->typeId = 2; // ID of block type
$block->getContent()->setAttributes(array(
'contentRss' => array($entry->id)
));
$success = craft()->matrix->saveBlock($block);
The code saves the new block and entry, but when I view the entry it has not linked the entry. I notice in the database tables it has not created an entry in the craft_relations table.
Where am I going wrong? :)