Reputation: 2996
I have two tables:
Using cakePHP, what would be the correct syntax of using $belongsTo in city model to auto populate the countries drop down?
Upvotes: 0
Views: 726
Reputation: 17516
City Model
class City extends AppModel{
var name = "City";
var $primaryKey = "objid";
var $belongsTo = array('Country' => array('className' => 'Country','foreignKey' =>'country_id'));
}
County Model
class Country extends AppModel{
var name = "Country";
var $primaryKey = "objid";
var $hasMany = array('City');
}
Upvotes: 1