Log message #4209686

# At Username Text
# Oct 19th 2019, 14:19 kailas @ndm ah, yeah, the debugs of the pre-save and the patch arrays was key. part of the problem was the [$i]. should have been .$i. in my form input. now the problem is that it’s trying to create new order lines, rahter than associate with the existing ones
# Oct 19th 2019, 14:13 kailas k
# Oct 19th 2019, 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 2019, 14:12 kailas to be clear, i’m patching a newEntity that is empty
# Oct 19th 2019, 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 2019, 14:11 kailas @ndm ok, cool, will try it!
# Oct 19th 2019, 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 2019, 14:06 kailas @ndm the form inputs are inside a foreach that’s iterating through all the lines I can add
# Oct 19th 2019, 14:04 kailas @ndm so, to put it all in one place, https://gist.github.com/kailasnarendran/ef0bb5536cb9d13a97e5ac3ad4d82252 . does that look right?
# Oct 19th 2019, 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 2019, 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 2019, 13:57 kailas Do I need to define that explicitly as well?
# Oct 19th 2019, 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 2019, 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 2019, 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 2019, 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 2019, 13:49 kailas @ndm is that the @this->Shipments->patchEntity ?
# Oct 19th 2019, 13:48 kailas @ndm hrm.. i’m sorry, i don’t understand what you mean by “your path is missing the property”
# Oct 19th 2019, 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 2019, 13:46 kailas @ndm shipment_handling_units[0].order_lines[]._joinData.order_line_id = … ?
# Oct 19th 2019, 13:45 kailas @ndm oh, i see, so i should get rid of the $i?
# Oct 19th 2019, 13:45 ndm *c
# Oct 19th 2019, 13:45 ndm Wait, all keys except x
# Oct 19th 2019, 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 2019, 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 2019, 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 2019, 12:54 admad When I am faced with such a situation I usually just keep mum :slightly_smiling_face:
# Oct 19th 2019, 12:39 alexdd55976 I would, but I have no experience with all that :,)
# Oct 19th 2019, 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 2019, 12:18 loginews @alex. thanks. something else must be wrong. I will investigate.
# Oct 19th 2019, 11:28 alexdd55976 @loginews no, there is no cache. You can see the entries instantly in the database.
# Oct 19th 2019, 09:54 arif.h how to use form element in cake
# Oct 19th 2019, 09:26 loginews Is there then a cache which I have to flush somewhere ?
# Oct 19th 2019, 09:25 loginews My use of cakephp is more or less limited to crud screens generated by the bake utility.
# Oct 19th 2019, 09:24 loginews I had this situation a couple of times. When I tried to look into the problem, the latter disappeared.
# Oct 19th 2019, 09:23 loginews Part of my application is written in pure php.
# Oct 19th 2019, 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 2019, 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 2019, 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 2019, 02:42 night_wulfe I realize it's a broad question, but any tips would help.
# Oct 19th 2019, 02:39 slackebot1 necessarily when to do it or what should go where.