# |
Jun 27th 2017, 07:19 |
savant |
https://book.cakephp.org/3.0/en/orm/saving-data.html#converting-hasmany-data |
# |
Jun 27th 2017, 07:19 |
savant |
i’ll bet you an ice cream |
# |
Jun 27th 2017, 07:18 |
savant |
i guarantee you its documented |
# |
Jun 27th 2017, 07:18 |
sebollson |
i did |
# |
Jun 27th 2017, 07:18 |
savant |
you didnt read the docs |
# |
Jun 27th 2017, 07:18 |
sebollson |
this should be better documented |
# |
Jun 27th 2017, 07:18 |
savant |
no problem |
# |
Jun 27th 2017, 07:18 |
sebollson |
thank you very much |
# |
Jun 27th 2017, 07:18 |
sebollson |
yes you are right |
# |
Jun 27th 2017, 07:18 |
sebollson |
es |
# |
Jun 27th 2017, 07:18 |
sebollson |
. |
# |
Jun 27th 2017, 07:17 |
savant |
‘user_roles’ => [[‘active’ => 1, ‘display’ => ‘root’]] |
# |
Jun 27th 2017, 07:17 |
savant |
since it is hasMany, you need to have an array of user_role arrays |
# |
Jun 27th 2017, 07:17 |
sebollson |
relation is just ommited ;/ |
# |
Jun 27th 2017, 07:16 |
sebollson |
userRoles |
# |
Jun 27th 2017, 07:16 |
sebollson |
userroles |
# |
Jun 27th 2017, 07:16 |
sebollson |
like user_roles |
# |
Jun 27th 2017, 07:16 |
sebollson |
i tired different keys |
# |
Jun 27th 2017, 07:16 |
sebollson |
This does not saves UserRoles |
# |
Jun 27th 2017, 07:16 |
rudy1976s |
Hi @savant sorry I did search badly, thank you |
# |
Jun 27th 2017, 07:16 |
sebollson |
], ['validate' => false]); |
# |
Jun 27th 2017, 07:16 |
sebollson |
] |
# |
Jun 27th 2017, 07:16 |
sebollson |
"name" => "admin" |
# |
Jun 27th 2017, 07:16 |
sebollson |
"UserRoles" => [ |
# |
Jun 27th 2017, 07:16 |
sebollson |
"active" => 1, |
# |
Jun 27th 2017, 07:16 |
sebollson |
"display" => "root", |
# |
Jun 27th 2017, 07:16 |
sebollson |
"email" => "root@localhost", |
# |
Jun 27th 2017, 07:16 |
sebollson |
$root = $this->Users->newEntity([ |
# |
Jun 27th 2017, 07:16 |
sebollson |
]); |
# |
Jun 27th 2017, 07:16 |
sebollson |
'foreignKey' => 'user_id' |
# |
Jun 27th 2017, 07:16 |
sebollson |
$this->hasMany('UserRoles', [ |
# |
Jun 27th 2017, 07:15 |
savant |
What is the problem? |
# |
Jun 27th 2017, 07:14 |
sebollson |
i got a problem with saving relations |
# |
Jun 27th 2017, 07:14 |
sebollson |
hi there |
# |
Jun 27th 2017, 07:08 |
savant |
> This public property will be removed in 4.0.0. Use getUri()->getPath() instead. |
# |
Jun 27th 2017, 07:08 |
savant |
did you check the docblock? It shows the alternative |
# |
Jun 27th 2017, 07:07 |
rudy1976s |
Hello since $this->request->here is deprecated , what is the correct way to obtain the same result ? |
# |
Jun 27th 2017, 06:29 |
savant |
otherwise do `$data[$alias][$key]->recid = $j++` if it is an object. |
# |
Jun 27th 2017, 06:29 |
savant |
so you need to check if its an array and do what you’re doing now |
# |
Jun 27th 2017, 06:29 |
savant |
not an array |
# |
Jun 27th 2017, 06:29 |
savant |
well `$data[$alias][$key]` is probably an object |