I am using Auth component for user login and registration. I want to add Country and State dropdowns to my User Model. Can someone help me with the required association in the Model files?
class User extends AppModel {
var $name = 'User';
var $belongsTo ="Country" ;
}
<?php
class Country extends AppModel {
var $name = 'Country';
var $hasMany = array('User');
}?>
My view:
echo $form->input('country_id');
But I am getting an empty dropdowm!
Your belongsTo definition is incorrect. The belongsTo attribute must be an array:
Then in your Users controller, ensure you’re getting the list of countries:
And your view will look something like: