I love the new ORM, but I'm having real trouble here.
I used the built-in "baking" system, to create the Controllers, Tables,
Entities etc off of my database model. I want to add a new row to the
"orders" table. There's one main association: Order belongsTo Call. This is
what I'm trying to do to save a new Order and add a new Call at the same
time:
$newOrder = $this->Orders->newEntity([
'call' => [
'user_id' => 1,
'customer_id' => 1,
'result_id' => 0
],
'delivery' => 1
]);
$this->Orders->save($newOrder);
The error that I'm getting is:
Array
(
[call_id] => Array
(
[0] => This field is required
)
)
call_id is a required field, yes, but I'd like to save both of them at the
same time. The documentation is rather .. not clear? Judging by this tweet
<https://twitter.com/cakephp/status/453891194003537920> it also looks like
this should be possible. I already checked the $_accessible variables and
they seem perfectly fine as well. Do I really have to go the long route and
start chaining Entities (as described here
<http://book.cakephp.org/3.0/en/orm/saving-data.html#saving-belongsto-associations>)
or can this still be done with the newEntity method? Thanks for any help in
advance.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.