# |
Jul 5th 2017, 14:38 |
pedroseco |
so be creating those new entities before i do the $this->Posts->save() i probably should append those into Posts too like you mentioned |
# |
Jul 5th 2017, 14:36 |
jeremyharris |
then I think you want to include the id in the Posts array |
# |
Jul 5th 2017, 14:36 |
pedroseco |
let me try it anyway. |
# |
Jul 5th 2017, 14:36 |
jeremyharris |
hm |
# |
Jul 5th 2017, 14:35 |
pedroseco |
probably not since the Posts model is the one who is doing the ->save() after |
# |
Jul 5th 2017, 14:34 |
jeremyharris |
I think you want what’s in the second comment. There should be a post in there |
# |
Jul 5th 2017, 14:34 |
pedroseco |
*Posts |
# |
Jul 5th 2017, 14:34 |
pedroseco |
let me add the associated key _joinData into Poss |
# |
Jul 5th 2017, 14:34 |
jeremyharris |
that’s from the first comment? |
# |
Jul 5th 2017, 14:34 |
pedroseco |
yes i think thats it |
# |
Jul 5th 2017, 14:34 |
pedroseco |
its already there, but it doesn’t get saved into database. |
# |
Jul 5th 2017, 14:34 |
pedroseco |
with the result entity. |
# |
Jul 5th 2017, 14:34 |
jeremyharris |
you might need to include Posts._joinData in the ‘associated’ key in the options to make sure it marshals. If you debug the entity and it’s missing association, that’s probably it |
# |
Jul 5th 2017, 14:34 |
pedroseco |
ok so almost there, i made a comment too |
# |
Jul 5th 2017, 14:33 |
jarard01 |
neon1024, I just tried hooking my Links model up to LinksImages and making it a hasMany relationship, it works so looks to be an issue - I'll create an issue of rit |
# |
Jul 5th 2017, 14:33 |
jeremyharris |
I added another comment to what I think it should be |
# |
Jul 5th 2017, 14:32 |
pedroseco |
let me try |
# |
Jul 5th 2017, 14:31 |
pedroseco |
ah i see |
# |
Jul 5th 2017, 14:31 |
pedroseco |
let me check, the association is Files belongsToMany Posts |
# |
Jul 5th 2017, 14:29 |
jeremyharris |
(I think I’m missing the name of the joined association though |
# |
Jul 5th 2017, 14:29 |
jeremyharris |
I added a comment on the gist |
# |
Jul 5th 2017, 14:28 |
jeremyharris |
what I would do is make an array, and pass that into newEntity |
# |
Jul 5th 2017, 14:28 |
jeremyharris |
yes, it needs to be an entity at that point |
# |
Jul 5th 2017, 14:28 |
pedroseco |
and of course it doesn’t work since _joinData is a empty value at that point. |
# |
Jul 5th 2017, 14:27 |
pedroseco |
@jeremyharris ok probably i’m doing this wrong but i was just adding it like this: https://gist.github.com/pedroseco/327628be11c6207c5e6aa6c708494313 |
# |
Jul 5th 2017, 14:26 |
jarard01 |
Links isn't related to any other Models |
# |
Jul 5th 2017, 14:26 |
jarard01 |
just to confirm - my model is 'Links' and I want to store one image upload to 'Links' |
# |
Jul 5th 2017, 14:26 |
jeremyharris |
@pedroseco I think since it’s an entity at that point, _joinData needs to be an entity too. Or, you can create an array that already includes the _joinData array and use that when creating the entity and it’ll be marshaled into an entity for you |
# |
Jul 5th 2017, 14:25 |
neon1024 |
Or both! :P |
# |
Jul 5th 2017, 14:25 |
neon1024 |
Could be a bug or a missing test case perhaps |
# |
Jul 5th 2017, 14:25 |
neon1024 |
Or if you want to download the repo to it’s own folder and try out the test suite :slightly_smiling_face: |
# |
Jul 5th 2017, 14:25 |
jeremyharris |
@pedroseco can you gist the entity after you add the _joinData property to it? |
# |
Jul 5th 2017, 14:25 |
neon1024 |
Hmm, can you submit and issue for it please? Then I can try and take a look at it :slightly_smiling_face: |
# |
Jul 5th 2017, 14:25 |
jarard01 |
in the process method of ProfferBehavior if I debug($uploadList); it is empty |
# |
Jul 5th 2017, 14:24 |
jarard01 |
yes, and yes - I use the multi upload on another model |
# |
Jul 5th 2017, 14:24 |
neon1024 |
The plugin is loaded isn’t it? |
# |
Jul 5th 2017, 14:24 |
neon1024 |
jarard01, ..and the edit template is the Links edit form? |
# |
Jul 5th 2017, 14:23 |
pedroseco |
@jeremyharris it seems I can’t set the _joinData after I created the newEntity() for the foreign model. Any more ideas? |
# |
Jul 5th 2017, 14:23 |
jarard01 |
mine is consistent: https://gist.github.com/spacebiscuit/0008bf634f24f15d4b41a392c3131700 |
# |
Jul 5th 2017, 14:19 |
neon1024 |
https://github.com/davidyell/CakePHP3-Proffer-Example/blob/master/src/Template/Posts/edit.ctp#L16-L30 |
# |
Jul 5th 2017, 14:19 |
neon1024 |
https://github.com/davidyell/CakePHP3-Proffer-Example/blob/master/src/Model/Table/PostsTable.php#L42-L49 |