# |
Jun 22nd 2018, 07:58 |
neon1024 |
Yeah, but there is no need to use events for that, as you’ll surely know that when you create your Pen |
# |
Jun 22nd 2018, 07:58 |
birdy247 |
A Ruler can only be saved after a Pen. Not all Pens create Rulers |
# |
Jun 22nd 2018, 07:57 |
neon1024 |
Then I would think about front-loading the problem, to manage the conditional nature earlier, so I could save everything in one go |
# |
Jun 22nd 2018, 07:57 |
neon1024 |
This scenario makes me stop and think, this is a code smell. Where does my software design stink enough that I need so many dependent events |
# |
Jun 22nd 2018, 07:55 |
birdy247 |
I would also like Rulers to be returned if they were saved |
# |
Jun 22nd 2018, 07:55 |
birdy247 |
actually I didnt explain this well.. A "Paper" is saved.. in the afterSave of paper, an event is emitted. This event then saves a Pen, which may then save a Ruler in the afterSave. Pens are then returned to the "Paper" in the event result |
# |
Jun 22nd 2018, 07:53 |
neon1024 |
So if anything was observing that event it could get both entities in the event subject |
# |
Jun 22nd 2018, 07:53 |
neon1024 |
Then I could pass both the Pen and Ruler with the event |
# |
Jun 22nd 2018, 07:53 |
birdy247 |
ah right, which contains the Pen id? |
# |
Jun 22nd 2018, 07:52 |
birdy247 |
I thought about stamping some guid on the records to show they are linked, and then performing a find with any records matching these guids |
# |
Jun 22nd 2018, 07:52 |
neon1024 |
So in the afterSave if a Ruler was created, I would emit an event there |
# |
Jun 22nd 2018, 07:52 |
neon1024 |
I would use an event |
# |
Jun 22nd 2018, 07:51 |
birdy247 |
The result gets passed elsewhere |
# |
Jun 22nd 2018, 07:51 |
birdy247 |
@tim Its not for display |
# |
Jun 22nd 2018, 07:42 |
tim |
@birdy247 Where/why do you need to know this? If it's just for displaying purposes, use FlashComponent |
# |
Jun 22nd 2018, 07:41 |
tim |
I'm unsure, we don't use bake here so I'm not that familiar with it :P |
# |
Jun 22nd 2018, 07:40 |
ra7bi |
Okay i will try now So by baking that structure cake will create for me that forms ? |
# |
Jun 22nd 2018, 07:39 |
tim |
The tables are fine (ideally it should be called fishes_shipments but you can just set the name you're using in your association) |
# |
Jun 22nd 2018, 07:38 |
ra7bi |
@tim can you give simple example how tables should look like? Currently I've Fishes Shipments Shipments_fishes ( shipment_id,fish_id) |
# |
Jun 22nd 2018, 07:36 |
tim |
@ra7bi You need to save your shipment before the shipment_fishes, otherwise it will have no ID and thus can't put that in the pivot table. If you use proper associations and form keys/names, it should all do this for you |
# |
Jun 22nd 2018, 07:35 |
ra7bi |
I don't really know |
# |
Jun 22nd 2018, 07:34 |
birdy247 |
Is there a cake way to do this |
# |
Jun 22nd 2018, 07:34 |
ra7bi |
I need to store shipment_fishes before shipment get stored |
# |
Jun 22nd 2018, 07:34 |
birdy247 |
The controller needs to know if a Pen and Ruler was created, or just a Pen |
# |
Jun 22nd 2018, 07:33 |
birdy247 |
In a controller, this initiates a save for a Pen, when a Pen is saved, in the afterSave it *might* create a Ruler (depending on the type of Pen) |
# |
Jun 22nd 2018, 07:32 |
ra7bi |
So when i open add shipment i will see Shipment details (shipment table) under that User can add different fishes Finally can save the shipment, it will get stored Shipment with related fishes |
# |
Jun 22nd 2018, 07:31 |
ra7bi |
In add new shipment I've 2 forms one for shipment details and other for adding fishes the idea is I can add as much as i want of fishes for each shipment |
# |
Jun 22nd 2018, 07:29 |
tim |
Is it not stored in the jointable? What code are you using to save it |
# |
Jun 22nd 2018, 07:29 |
ra7bi |
Hopefully my question is clear , for more clarification please let me know |
# |
Jun 22nd 2018, 07:28 |
ra7bi |
Hello all , I've a case and I don't know how cakephp deals with it I've 3 tables 1: fishes 2: shipments_fishes 3: shipments When creating new shipment i store all fishes for that shipment in shipments_fishes table which contains Shipment id and fishe id The problem is how to get shipment id and still not stored in the DB |
# |
Jun 22nd 2018, 07:22 |
tim |
If you explicitly define it as a select, you'd get the same result |
# |
Jun 22nd 2018, 07:22 |
tim |
You don't need to, that's just what it uses for guesstimating what type of input it is |
# |
Jun 22nd 2018, 07:17 |
Magiq |
here for example |
# |
Jun 22nd 2018, 07:17 |
Magiq |
https://api.cakephp.org/3.6/source-class-Cake.View.Helper.FormHelper.html#1366 |
# |
Jun 22nd 2018, 07:16 |
birdy247 |
Where does it force you? |
# |
Jun 22nd 2018, 07:16 |
Magiq |
Why cakephp force to use underscore in column names ? |
# |
Jun 22nd 2018, 07:14 |
birdy247 |
Morning |
# |
Jun 22nd 2018, 06:59 |
magiq__ |
test |
# |
Jun 22nd 2018, 06:52 |
magiq__ |
i'm speaking about columns |
# |
Jun 22nd 2018, 06:52 |
magiq__ |
what ? |
# |
Jun 22nd 2018, 06:48 |
saeideng |
`$this->setTable('tablename');` |