damacri86
damacri86

Reputation: 295

CakePHP many to many relation with extra field

I have a problem with my Many to Many relation:

I have two tables related with many to many relation

and the association table

My problem is how to add these extra fields. I don't know how to configure the model of the two entities.

Please, can someone help me with this? Thanks

Upvotes: 0

Views: 254

Answers (1)

Nunser
Nunser

Reputation: 4522

You need to change your relations. As stated in the docs, the relations transform to

Table1 hasMany Table1_Table2
Table1_Table2 belongsTo Table1, Table2
Table2 hasMany Table1_Table2

Then you need to create a model Table1_Table2 in your model folder and treat it like any other belogsTo-hasMany association, but you can add more fields (and validation if you want).

Upvotes: 1

Related Questions