Getting a dropdown of items a model hasMany of, should be very easy to do, but I always forget and it takes me far longer to find it than it should.
For this brief example, we’re assuming that we have an Uploads model and a FileCategory model.
Uploads belongs to FileCategory and File Category has many Uploads … get it?
class Upload extends AppModel { var $belongsTo = array('Client', 'FileCategory'); } class FileCategory extends AppModel { var $hasMany = array('Upload'); } |
All you need to do to is get the items for the dropdown with a find(‘list’) command and then Continue reading