I have two tables: users and firms:
class Firm extends AppModel {
var $name = 'Firm';
var $hasAndBelongsToMany = 'User';
}
and
class User extends AppModel {
var $name = 'User';
var $hasMany ='Post';
var $hasAndBelongsToMany = 'Firm';
}
I use scaffold var to display all save / view / edit methods, etc. I override the add method as follows:
function add(){
if (!empty($this->data)) {
$this->User->create();
$this->User->save($this->data);
$this->redirect(array('action'=>'index'), null, true);
}
$firms = $this->User->Firm->find('list');
$this->set('firms', $firms);
}
Everything works fine, but when I use users / add, I have a popup menu with an identifier: "1", "2", etc.
I would like to display the name of the company, not the identifier. How to do it?
source
share