I have two tables:
- countries with fields [objid(PK), name]
- cities with fields [objid(PK), name, country_id(FK)]
Using cakePHP, what would be the correct syntax of using $belongsTo in city model to auto populate the countries drop down?
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?
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');
}