Baked tempate is incomplete regarding assosications

Hello there!

I have two tables “bills” and “billpayments”. The schema is like this:
bills: id (pk, int, notnull, unsigned, autoinc) | amount (float, unsigned)
billpayments: id (pk, int, nn, un, ai) | bill_id (pk, int, nn, un, autoinc)

When I bake mvc-files of these tables, all associations are detected correctly (bill hasMany Billpayments and Billpayments belongsTo bill).

But the baked template for BillPayments has no input-field for selected the corresponding bill_id. But the view has an Array “Bills” with all IDs (no more data but the ids).

The User-Field (not shown in table above) has been created, is visible and the usernames are displayed.

Did I do something wrong? Why is users-input being created, while bills is not.

When I copy the user-input-field and replace the $options-source with $bills (instead of $users), this new input-field is created with the attribute hidden and the SQL-Statement for selecting bills is being showed in the sourcecode (html browserside).

Thanks in advance

Hello, to answer the question by myself - In bills_payments I marked id AND bill_id as primary key by accident. Took me 4 hours to realize what the mistake was. Cake did its job fine - not like me :wink:

1 Like