I would love to know the answer to this one as well - https://stackoverflow.com/questions/24447879/cakephp-habtm-i-want-duplicates-at-save
I've tried a few different things in regards to unique = false, saveAll saveAssocaited, array formatting. No luck.
My specific example is passing this array of data, and I'm using saveAll in my AvailablePackageController:
'AvailablePackage' => array(
'title' => 'Tester',
'description' => 'Tester description',
'price' => '500.00',
'image' => array(
'name' => '',
'type' => '',
'tmp_name' => '',
'error' => (int) 4,
'size' => (int) 0
)
),
'AvailableLesson' => array(
'AvailableLesson' => array(
(int) 0 => '23',
(int) 1 => '23',
(int) 2 => '23',
(int) 3 => '9',
(int) 4 => '9'
)
)
As you can see I'd like this Available Package to have the Available Lesson '23' associated 3 times. As within a package you can take the same lesson 3 times over (in this case).
HABTM is setup correctly and all works as expected. In the above it saves 2 rows one for 23 and one for 9. So no issues in configuration of the relationship. It just won't save duplicates.
Any help would be greatly appreciated. Thanks.