# |
Apr 21st 2017, 10:21 |
technofection |
@hmic The bottom line is, I already have some records in the hasMany associaton and now wnated to push another new one... So I'd fetch the main entity along with contain, and then push a new entity in the hasMany association array, save the main entity back... This should create a new reocrd in the hasMany table.. But its not doing so :( |
# |
Apr 21st 2017, 10:20 |
dorxy |
I’ve checked the `_buildPropertyMap` function in the marshaller, which created an anonymous function for association B with `['associated' => ['C']]`, but when I try to debug inside that anonymous function it seems to never be called :( |
# |
Apr 21st 2017, 10:18 |
dorxy |
Could someone help me with associations maybe? I’ve got the following entities: A hasMany B and B belongsTo C containing on those entities works, but when I patch an entity with `['associated' => 'B.C']` in the options, C is not loaded as an entity onto B, but I do require it when someone submits a form and there are errors |
# |
Apr 21st 2017, 10:17 |
technofection |
I already have one, and pushed another one in the entity array.. The new one I pushed into the array is not saving, neither there is any error in the main entity :( |
# |
Apr 21st 2017, 10:16 |
technofection |
https://gist.github.com/technofection/f25941b073061eba41b758f9e6f3db47 |
# |
Apr 21st 2017, 10:16 |
hmic |
if you provide only one, it will replace the ones with what you save by the default save strategy |
# |
Apr 21st 2017, 10:15 |
hmic |
check the save strategy on the association |
# |
Apr 21st 2017, 10:15 |
hmic |
!tell technofection about gist |
# |
Apr 21st 2017, 10:15 |
slackebot |
[phone_country_id] => [phone_type_id] => 1 [status] => 0 ) [1] => Array ( [phone_type_id] => 2 [phone] = 2323232323 ) ) ) |
# |
Apr 21st 2017, 10:15 |
technofection |
Array ( [id] => 91 [first_name] => My [middle_name] => [last_name] => Brother [email] => lkjlkj@sdfsdf.co> [birth_date] => [gender] => [preferred_name] => [social_security_number] => [person_phone_numbers] => Array ( [0] => Array ( [id] => 68 [person_id] => 91 [phone] => 7679748636 |
# |
Apr 21st 2017, 10:14 |
technofection |
I want to add another phone number in the PersonsPhoneNumbers |
# |
Apr 21st 2017, 10:13 |
technofection |
Now in Persons table I have one person and then I have one record in PersonPhoneNumbers |
# |
Apr 21st 2017, 10:12 |
technofection |
I have an association like Person HasMany PersonPhoneNumbers |
# |
Apr 21st 2017, 10:10 |
technofection |
Not really.. give me a moment... On a call :slightly_smiling_face: |
# |
Apr 21st 2017, 10:10 |
hmic |
technofection: does this answer your main question too? :D |
# |
Apr 21st 2017, 10:09 |
hmic |
maybe provide an example array in the code comment to make it clear: [Articles.Comments] |
# |
Apr 21st 2017, 10:08 |
Junior |
n the end i have submitted an issue for the footprint plugin. Blocks of code available at: https://github.com/UseMuffin/Footprint/issues/46 . If anyone has any idea, please share it with me! |
# |
Apr 21st 2017, 10:07 |
dereuromark |
thats what I thought |
# |
Apr 21st 2017, 10:07 |
hmic |
it can be a deep save, use . notation |
# |
Apr 21st 2017, 10:07 |
hmic |
true is only a shortcut for saving up one level |
# |
Apr 21st 2017, 10:07 |
technofection |
Yes, it can be array, but upto 1 level |
# |
Apr 21st 2017, 10:07 |
hmic |
you can save deep with this |
# |
Apr 21st 2017, 10:06 |
hmic |
arrays take . notation |
# |
Apr 21st 2017, 10:06 |
hmic |
ah, it's right there, you can pass arrays too |
# |
Apr 21st 2017, 10:06 |
hmic |
you can pass arrays to associated too IMHO |
# |
Apr 21st 2017, 10:05 |
technofection |
associated: If true it will save 1st level associated entities as they are found in the passed $entity whenever the property defined for the association is marked as dirty. If an array, it will be interpreted as the list of associations to be saved. It is possible to provide different options for saving on associated table objects using this key by making the custom options the array value. If false no associated records will be saved. |
# |
Apr 21st 2017, 10:04 |
technofection |
https://api.cakephp.org/3.3/class-Cake.ORM.Table.html |
# |
Apr 21st 2017, 10:04 |
hmic |
where would the docs say so? |
# |
Apr 21st 2017, 10:04 |
technofection |
But now the main question.. |
# |
Apr 21st 2017, 10:04 |
dereuromark |
Well, there you go then |
# |
Apr 21st 2017, 10:04 |
technofection |
The docs says 1 level though.. |
# |
Apr 21st 2017, 10:03 |
dereuromark |
I ever saved 1 level deep, but others might know more. I would suspect it to be able to save deeper. |
# |
Apr 21st 2017, 10:03 |
dereuromark |
I think you should ask the whole channel here. |
# |
Apr 21st 2017, 10:03 |
technofection |
The first question is, I can only save associated data upto 1 level, right? |
# |
Apr 21st 2017, 10:02 |
technofection |
I already asked this before some time here, but here it is again |
# |
Apr 21st 2017, 10:01 |
dereuromark |
sure |
# |
Apr 21st 2017, 10:01 |
technofection |
Hi @dereuromark , Can I ask you one question please? |
# |
Apr 21st 2017, 10:01 |
rudy1976s |
I will try again with FP |
# |
Apr 21st 2017, 09:59 |
rudy1976s |
ok @dereuromark |
# |
Apr 21st 2017, 09:59 |
dereuromark |
Dont get that part :slightly_smiling_face: |
# |
Apr 21st 2017, 09:59 |
dereuromark |
But why would you then ask a generic question again? "Hello is there a way to inject variables into events like beforeSave, available for all models" |