i’m currently working on my first project with yii - so i’m new to yii.
The Problem i’m having at the moment is with a identifying relation and how to save it:
table 1: order
id (pk)
address
orderdate
orderstate
…
table 2: handOrder
orderId (pk,fk)
quality
color
tv
th
…
So i have one table where all orders go in with the data wich is similar for all the orders. depending on what kind of order it is, the details of the order go into another table. In this example this is only one table, the handOrder. An entry in the handOrder table only makes sence and can only exits with an entry in the order table (1:1 identifying relation).
My question now is, if it is possible to automaticly validate and save the related model, when the main model is saved? Or the other way round…validate and save the main model when the related model is saved. I don’t care.
Or is the only way to manualy save the other model?
If you are going to collect the input of both table in a single form, you can validate all field and then in your code manually set the foreign key field right before save.
If you collect the input of handorder in a different form, you will use a dropdown or something similar, and you can use CExixtValidatorfor validation.