some time ago I've asked for something similar, but now I'm picking up with this, so asking again.
Maybe this question can sound simple but it's not for me.
I have two tables:
header (id,date,field1,field2) // This has One entry on the table
detail (id,idheader,field1,field2) // This can have multiple entries on the table
so header (1) ---> detail (N)
Which can be the best method to make a form and upate on the same $f->update() these two tables ?
Imagine that this can be a lot of things: an invoice, a budget, etc, etc
Very thanks
traditional approach would be to have grid with "header" and add column expander, which shows grid with "detail" and model "detail" has setMasterField("idheader", $_GET["header_id"]);
e.g.
not tested.
It looks like your logical model is physically located in two tables. First, decide which table is "primary", it can be either way. I'll make "header" table primary by creating the following model:
Next you need to join it with your second table and add fields from it. When you call $model->join() it returns "SQL_Relation" object back to you which can be used to add additional fields and creating more joins. You can create either a new object or extend your existing.
Because both tables define same field and model must have unique field, I defined a new name for detail.field1. I also explicitly specified field used for joining (idheader). Next, you are using new model just like any other model: