Reputation: 749
I have encountered a problem whilst saving belongsToMany associations and the data being saved is a combination of existing entities and new entities.
The data array is as follows:
$data = [
'tags' => [
['label' => 'Some new tag'],
['label' => 'Another new tag'],
'_ids' => [1, 2]
]
];
Is it that these two methods of saving this association cannot be used together?
I have tried creating a data array where each entity is its own array item like the following:
$data = [
'tags' => [
['label' => 'Some new tag'],
['label' => 'Another new tag'],
['id' => 1],
['id' => 2]
]
];
But when it is just ids this does not create new associations. Do I need to handle the creation of new entities first and then create the associations using the ['_ids'] methods, or is there something wrong with my data array?
Upvotes: 0
Views: 709
Reputation: 749
The seconds $data array structure is now possible as of this commit https://github.com/cakephp/cakephp/commit/0333639025780d2400b1888d0a2d1cab6c76d37a.
Upvotes: 1