Question

I have a new model myModel that I'm creating with a one-to-many relationship to a bunch of sub-models mySubModel that are being created at the same time.

when I try to save the model:

<cfset myModel=model("myModel").new(params.mymodel)>
<cfset myModel.save()>

only the model part gets saved, the items inside params.myModel.mySubModels do not get created. The models have their relations setup and I can get it to pull the data in the same format out of myModel with the right include.

I could save each of the models separately, but I'm worried about that causing problems or just creating needles lines of code if cfwheels is able to handle this already. I would have to save the initial model and then save the additional sub-models, and if there is an error, delete the model and other sub-models that have already been written to the database.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top