mercredi 6 mai 2015

CakePHP: Multiple Model in Controller Action:add

I just started with CakePHP recently. The framework make things easy, but today I just find myself a new question.

If a Project model has an image, it would be accessible somewhere like $this->data['Project']['image']. Since there's only 1 image to 1 project, it can be a field in the Project table itself.

But what about if Project has a collection of images? Wouldn't it be another table say Gallery? Then we're talking about two Model here.

For the previous case, image can easily be uploaded in project/add, storing the filename into projects.image. Things happen in Project Model, and Project Controller.

Now how's the cake way to do it when adding a Project with a Gallery?

Aucun commentaire:

Enregistrer un commentaire