nino
nino

Reputation: 861

CakePHP Foreign Key Display Value

I know this is probably really easy to do, but I can not figure it out. And I didn't find an example on Google.

I have a table 'statuses' and a table 'events'. 'events'.'statuses_id' connects to 'statuses'.'id'. Now when I make a find('all') on the event model i still get the id i entered into the database. I would like to display the field 'statuses'.'name'.

Could someone help me on how to do this? I know i have to somehow declare the fk-connection in the model, but how?

Upvotes: 1

Views: 461

Answers (1)

pollirrata
pollirrata

Reputation: 5286

Use the belongs_to reference ("Event belongsTo Statuses") and cake automatically will bring you both the name and the id

Upvotes: 2

Related Questions