Log message #4209684

# At Username Text
# Oct 19th, 14:13 ndm Well, that might be (part of) your problem. Debug the entity after patching to check what it looks like, and make sure that your `save()` call uses the correct `associated` option too.
# Oct 19th, 14:12 kailas to be clear, i’m patching a newEntity that is empty
# Oct 19th, 14:12 kailas ugh. didn’t work. not sure how to debug this further (since it does save the shipmehandling unit and there are no errors)
# Oct 19th, 14:11 kailas @ndm ok, cool, will try it!
# Oct 19th, 14:10 ndm Generally that looks OK I think. Not sure if you actually need to put the foreign key in the form if the entity that you're patching contains all the associated entities.
# Oct 19th, 14:06 kailas @ndm the form inputs are inside a foreach that’s iterating through all the lines I can add
# Oct 19th, 14:04 kailas @ndm so, to put it all in one place, https://gist.github.com/kailasnarendran/ef0bb5536cb9d13a97e5ac3ad4d82252 . does that look right?
# Oct 19th, 14:01 ndm No, if there is no such association and it's just BTM, then this shouldn't be in the `associated` option (there are edge cases where you want to do something like that), and it should just be `ShipmentHandlingUnits.OrderLines`, in that case your original property path would be correct.
# Oct 19th, 13:59 kailas so ShipmentHandlingUnits belongsTo OrderLinesShipmentHandlingUnits (need to add this), so then I can create those entities that will link ShipmentHandlingUnits to OrderLines (via the BTM relationship)
# Oct 19th, 13:57 kailas Do I need to define that explicitly as well?
# Oct 19th, 13:57 kailas yeah, i don’t have an explicit association between ShipmentHandlingUnits and OrderLinesShipmentHandlingUnits (it’s just implied with the BTM between ShipmentHandlingUnits and OrderLines
# Oct 19th, 13:56 ndm No, I just cut of the rest because the problem is the missing association, assuming that the `associated` option is telling the truth.
# Oct 19th, 13:55 kailas oh, i see, so I don’t actually set the value of _joinData, i need to set those fields in .orderlines_shipment_handling_units[] explicitly? so shipment_handling_units[0].orderlines_shipment_handling_units[0].order_line_id=1, shipment_handling_units[0].orderlines_shipment_handling_units[0].qty=3, etc…
# Oct 19th, 13:53 ndm Your path is only two levels deep, but your association is three levels deep. It should be something like `shipment_handling_units[index].orderlines_shipment_handling_units[index].order_lines[index]...`
# Oct 19th, 13:49 kailas @ndm is that the @this->Shipments->patchEntity ?
# Oct 19th, 13:48 kailas @ndm hrm.. i’m sorry, i don’t understand what you mean by “your path is missing the property”
# Oct 19th, 13:47 ndm No no... sorry, I just need to wake up first, it needs and index too. But your path is missing the property for `OrderLinesShipmentHandlingUnits`.
# Oct 19th, 13:46 kailas @ndm shipment_handling_units[0].order_lines[]._joinData.order_line_id = … ?
# Oct 19th, 13:45 kailas @ndm oh, i see, so i should get rid of the $i?
# Oct 19th, 13:45 ndm *c
# Oct 19th, 13:45 ndm Wait, all keys except x
# Oct 19th, 13:45 kailas @ndm so my patch is : $this->Shipments->patchEntity($shipment, $this->request->getData(),[‘associated’=>[‘ShipmentHandlingUnits.OrderLinesShipmentHandlingUnits.OrderLines’]]); my individual lines are (iterating through the order lines) : <?=$this->Form->input(“shipment_handling_units[0].order_lines[$i]._joinData.order_line_id”,[‘type’=>‘hidden’,‘value’=>$orderLine->id]); ?>
# Oct 19th, 13:43 ndm The path is still wrong, all keys need an index ;) Anyways, by default only first level associations are patched and saved, for deeper associations you need to explicitly allow them using the `associated` option for patching and saving, maybe that's your problem.
# Oct 19th, 13:35 kailas I’m trying to create an entity A and B (and existing C) where : A has many B and B BelongsToMany C. in my patch entity array i include the a.b[0].c._joinData.stuff values. On my save, A and B are created, but the join table entities between B and C are not created (from the _joinData data). is that even possible?
# Oct 19th, 12:54 admad When I am faced with such a situation I usually just keep mum :slightly_smiling_face:
# Oct 19th, 12:39 alexdd55976 I would, but I have no experience with all that :,)
# Oct 19th, 12:33 admad In case anyone wants to weight in on this your thoughts are welcome https://github.com/cakephp/cakephp/pull/13766
# Oct 19th, 12:18 loginews @alex. thanks. something else must be wrong. I will investigate.
# Oct 19th, 11:28 alexdd55976 @loginews no, there is no cache. You can see the entries instantly in the database.
# Oct 19th, 09:54 arif.h how to use form element in cake
# Oct 19th, 09:26 loginews Is there then a cache which I have to flush somewhere ?
# Oct 19th, 09:25 loginews My use of cakephp is more or less limited to crud screens generated by the bake utility.
# Oct 19th, 09:24 loginews I had this situation a couple of times. When I tried to look into the problem, the latter disappeared.
# Oct 19th, 09:23 loginews Part of my application is written in pure php.
# Oct 19th, 09:21 loginews as for me, I used cakephp to input data, but it seems that pure php does not see the entries immediately. Is there a cache in cakephp that I should flush somewhere ?
# Oct 19th, 07:42 MaTTze I read in the docs I have to load the TwigView Plugin with boostrap and tried to add it in my Application.php but that didn't help.
# Oct 19th, 07:41 MaTTze Hi guys, maybe someone of you can help me. I started with a fresh cakephp-app-skeleton project and wanted to use bake. But I get an error 'Unknown "as_array" filter'.
# Oct 19th, 02:42 night_wulfe I realize it's a broad question, but any tips would help.
# Oct 19th, 02:39 slackebot1 necessarily when to do it or what should go where.
# Oct 19th, 02:39 slackebot1 to custom finders and save methods? How do you avoid making the custom find methods extremely complex trying to deal with all the possible options (conditions, fields, count, order, etc) that a user can pass in? Likewise, I feel like the model will end up with dozens of saveBySomeThing() methods to deal with all the variances in how something could be saved. Are there any guidelines available? The book seems to say how to do all this, but not
# Oct 19th, 02:39 night_wulfe I have a legacy CakePHP 2.x app that I'm maintaining and have an opportunity to refactor some code. Migrating to 3.x is on the road map, but not something I can do right now due to the size of the application. One of the things that seems wrong to me is the controllers all use find() and save() directly. There are no custom find/save methods and as a result a lot of duplicate code and logic in the controllers. Should all this be moved