Remove the validation rule for call_id. Validation is mostly meant for what the user submits and not the internal working of the ORM. When version 3.0RC is released this will become more obvious as validation will solely be executed for the request data and will not be used for this type of integrity checking.
On Sunday, December 14, 2014 9:01:25 PM UTC+1, Frodo wrote:
-- On Sunday, December 14, 2014 9:01:25 PM UTC+1, Frodo wrote:
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:The error that I'm getting is:
$newOrder = $this->Orders->newEntity([
'call' => [
'user_id' => 1,
'customer_id' => 1,
'result_id' => 0
],
'delivery' => 1
]);
$this->Orders->save($newOrder); 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 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) or can this still be done with the newEntity method? Thanks for any help in advance.
Array
(
[call_id] => Array
(
[0] => This field is required
)
)
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+unsubscribe@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.
No comments:
Post a Comment