I've 3 tables:
project
, amenities
and project_amenities
.
I add project form only, i want to add new amenities, which first added to amenities table and then project_amenities table.
So I defined these relations:
Project hasMany Amenities
Amenity belongsTo Project
I declared in projects_controller
:
var $uses = array('Amenity');
This gives error for my add action here
if (!empty($this->data)){
$this->Project->create();
as
Notice (8): Undefined property: ProjectsController::$Project
[APP\controllers\projects_controller.php, line 60]
edit Also, I cannot do:
$this->Amenity->create();
$insertData = array('name' => $this->data['Project']['Amenity'][$i]['name']);
$this->Amenity->save($insertData);