Foreign Keys

Richard's picture

CakePHP: Auto populating foreign key dropdown fields

One of the neet features of CakePHP's scaffolding is that it automatically populates your foreign key (belongsTo, hasAndBelongsToMany) fields in your forms.

Lets take a look at a simple example to illustrate this:

app/models/article.php:

class Article extends AppModel {
	var $hasAndBelongsToMany = array(
		"Tag"
	);
}

app/models/tag.php:

Syndicate content