No, you cannot have both if you use the _ids key. You can either send the 
data in 'relations' in the correct format by combining records with 
existing ids and new records or you can call newEntity or patchEntity twice 
by passing the correct format:

 [id] => 1
    [title] => entry 1
    [new_relations] => Array ( [0] => Array
                (
                    [status] => 1
                    [title] =>   test
                )) 
    [relations] => Array
        (
            [_ids] => Array
                (
                    [0] => 1
                    [1] => 3
                )
        )

$entity = $this->Articles->newEntity($data);
$data = ['relations' => $data['new_relations']];
$entity = $this->Articles->patchEntity($entity, $data); 

Or something along those lines... You could even marshal the new_entities 
by using the correct table, and the append those entities to the 
'relations' array and then save.

On Monday, August 11, 2014 10:00:14 AM UTC+2, Dieter Gribnitz wrote:
>
> When saving data that have new relations and a selection of relations only 
> the selection gets updated and new relations get discarded.
>
> example post:
>
>     [id] => 1
>     [title] => entry 1
>     [relations] => Array
>         (
>             [_ids] => Array
>                 (
>                     [0] => 1
>                     [1] => 3
>                 ),
>             [0] => Array
>                 (
>                     [status] => 1
>                     [title] =>   test
>                 )
>         )
>
> Is there a way to pass the data that will allow a user to select relations 
> + create new ones if they do not exist or do I need to create some kind of 
> data preprocessor to create the new entities and add their ids to the _ids 
> key before sending the data to the marshaller?
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to