2
votes

I'm trying to save IssueHistoryDescription, which belongsTo IssueHistory. So IssueHistory hasMany IssueHistoryDescription. This has all been set in the model.

Yet, when I save this in IssueHistory, using $IssueHistory->save($data);

(With or without a $IssueHistory->create(); before...)

Array
(
    [IssueHistory] => Array
        (
            [id] => 22
        )

    [IssueHistoryDescription] => Array
        (
            [old_description] => OLD
            [description] => NEW
        )

)

It doesn't work, nothing is saved.

When I try to use saveAssociated() I get an error:

Fatal error: Cannot use string offset as an array in /var/www/xdev/kipdomanager/cakephp/lib/Cake/Model/Model.php on line 2248

1
You can try cakephp saveAll() method... - thecodeparadox

1 Answers

4
votes

You can try this:

$data = array(
    'IssueHistory' => array('id' => 2),
    'IssueHistoryDescription' => array(
        array('old_description' => 'OLD', 'description' => 'new')
    )
);

$IssueHistory->create();
$IssueHistory->saveAll( $data );