I used the cakephp console to generate some CRUD operations. The generated code was buggy as the model of an associated model was not loaded by default in the controller.
For instance:
$programs = $this->Chantier->Program->find('list');
would not work, but:
$this->loadModel('Program');
$programs = $this->Program->find('list');
would. Here is the code of the associations:
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'Programs' => array(
'className' => 'Programs',
'foreignKey' => 'Programs_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Etats' => array(
'className' => 'Etats',
'foreignKey' => 'Etats_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Types' => array(
'className' => 'Types',
'foreignKey' => 'Types_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'ChampsLibres' => array(
'className' => 'ChampsLibres',
'foreignKey' => 'Champs_libres_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);